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
-
2You have a document.ready inside a window.load, why?Musa– Musa2012-05-02 20:18:20 +00:00Commented May 2, 2012 at 20:18
-
@Musa because I am not a skilled Javascript guy. It worked which is all that I wanted.Raymond Ablack– Raymond Ablack2012-05-02 21:14:10 +00:00Commented May 2, 2012 at 21:14
-
@RaymondAblack, don't edit your questions to say you've reached some limit. If you have an issue like this, check whether there's an answer on meta or ask a question there.Bruno– Bruno2012-05-09 23:17:55 +00:00Commented May 9, 2012 at 23:17
Add a comment
|
2 Answers
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.
2 Comments
Raymond Ablack
I could not get that to work. No value went to #the-hidden-field
Raymond Ablack
I tweaked your code a little and got it to work! Thanks so much for the push!