0

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

http://jsfiddle.net/YRWKH/

3
  • 2
    You have a document.ready inside a window.load, why? Commented May 2, 2012 at 20:18
  • @Musa because I am not a skilled Javascript guy. It worked which is all that I wanted. Commented 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. Commented May 9, 2012 at 23:17

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I could not get that to work. No value went to #the-hidden-field
I tweaked your code a little and got it to work! Thanks so much for the push!
0

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.

Comments

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.