Reputation: 9
I have a piece of code (JSFiddle link below), that generates a picture based on the radio button clicked. I would like to send the name of the resulting image to a form so it can be sent to a different page (payPal checkout). I can't seem to get it to work and I'm looking for help. Thanks
Upvotes: 0
Views: 61
Reputation: 148
Use a hidden input. onclick of the radio button, set the value to the path to the image, then on post, just simply $_POST to grab the image name.
Upvotes: 0
Reputation: 37803
First, add a field to your form:
<input type="hidden" name="some_name" value="" id="the-hidden-field" />
Then, in your updateImage()
function, you can do:
var src = "images/" + BodyColor + InsertColor + ".jpg";
$("#FinalImage").attr('src' src);
$('#the-hidden-field').val(src);
Now your hidden field has the same value as the src
attribute on the image itself, and of course the hidden field will be passed to the server as would any other field.
Upvotes: 1