Paul
Paul

Reputation: 11756

Can I pass javascript variable to a PHP form?

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=" ??? " />

Upvotes: 1

Views: 459

Answers (1)

user703016
user703016

Reputation: 37995

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>

Upvotes: 5

Related Questions