1
I created a code and I’m having problems with it.
I’ve tried them both individually, both Draggable
like the Resizablee
, and worked perfectly, altering the data in the input, and when updated recording in the Database.
But together they’re not working, I can only change the size of the image, and yet I’d like him to show me the scales in input, as the mouse moves, and this is not happening, because of the size that is it always starts from the scale 0.
If friends can give me that help, I’d be very grateful.
PS.: Below addresses for test page and ADM panel.
- http://www.pbfjacarepagua.com.br/teste/index.php
- http://www.pbfjacarepagua.com.br/teste/admin/painel/index.php
<script type="text/javascript">
$(window).load(function() {
$('#img').draggable({
drag: function() {
var offset = $(this).offset();
var xPos = offset.left;
var yPos = offset.top;
$('#posXimg').val('' + xPos);
$('#posYimg').val('' + yPos);
}
});
});
$(window).load(function() {
var startW = 0;
var startH = 0;
$('#img').resizable({
start: function(event, ui) {
startW = $(this).outerWidth();
startH = $(this).outerHeight();
},
stop: function(event, ui) {
endW = $(this).outerWidth();
endH = $(this).outerHeight();
$('#posWimg').val('' + endW - startW);
$('#posHimg').val('' + endH - startH);
}
});
});
</script>
<body>
<form name="enter" method="post" action="" enctype="multipart/form-data">
<label>Largura: </label>
<input type="text" id="posWimg" name="larg_img" value="<? echo $res['larg_img'];?>" />
<label>Altura: </label>
<input type="text" id="posHimg" name="altu_img" value="<? echo $res['altu_img'];?>" />
<label>Posicionamento: </label>
<input type="text" id="posXimg" name="hori_img" value="<? echo $res['hori_img'];?>" />
<input type="text" id="posYimg" name="vert_img" value="<? echo $res['vert_img'];?>" />
<input class="input" type="submit" name="enter" value="Atualizar" />
</form>
<br />
<img width="<? echo $res['larg_img'];?>" height="auto" title="CPanel" align="left" src="../../upload/<? echo $res['img'];?>" id="img" class="ui-draggable ui-draggable-handle" style="cursor: move; position: absolute; left: <? echo $res['hori_img'];?>px; top: <? echo $res['vert_img'];?>px;" />
</body>
</html>
Why are you using the
$(window).load()
distinctly for each of the features? Try to insert the drag and resize it and tell me what happens.– Erlon Charles
I don’t know if that’s what you. referred to as Erlon, but I removed the $(window). load() that was before the $('#img'). resizable, and keeps giving Chabu...rsrsrsr Now it ignores the resizable function, only draggable function is working. I’m sorry but I’m still very inexperienced in script! Would you like me to demonstrate how? Here is my thanks for your attention.
– Murilo Cabral