1

I'm using jcrop to crop my photos and need to send the current values along with my form submission. Is there an easy way to do this?

The JavaScript variable is this:

c = coords;
$.param(c)

Can I include this as a hidden field in my PHP form somehow?

<input type="hidden" name="coords" value=" ??? " />

1 Answer 1

5

Of course you can:

<form onsubmit='document.getElementById("your-hidden-field-id").value = c.toString(); return true;'>
...
<input type="hidden" name="coords" id="your-hidden-field-id"/>
</form>
Sign up to request clarification or add additional context in comments.

4 Comments

I'm trying the follwoing but crop_coords is always empty: <form id="process_image_form" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" onsubmit='$("#crop_cords").val() = $.param(c).toString(); return true;'>
The value of $.param(c).toString() is valid.
There are several things wrong in your code. First you probably mistyped crop_coords. Second, .val() is a getter, not a setter.
Cicada: That was it: $("#crop_cords").val($.param(c).toString()) worked! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.