Skip to content Skip to sidebar Skip to footer

How To Assign The Value Of A Javascript Variable To A Php Variable

I've a form.

JS:

$('#nameSave').click(
    function() {
        var pos = $('#name').position();
        $('#posLeft').val(pos.left);
        $('#posRight').val(pos.right);
    }
);

Solution 2:

add two hidden input to your form and use jQuery to change their value

Solution 3:

Try this:

var pos = $('#name').position();
$("form").append('<input type="hidden" name="name_position" value="' + pos.left + ',' + pos.top + '" />');

Then read name_position value from the POST data in the server side code.

Post a Comment for "How To Assign The Value Of A Javascript Variable To A Php Variable"