Jump to content

Passing Variable To Form


Kurash
 Share

Recommended Posts

I have a form that takes user input in a Select.Option dropdown box and passes that data to an ASP page the emails the data.My Option/Select code is below and works correctly. What I want to do it, when a person selects one of the values from the drop down I want to populate a second field which can be hidden or not from the user, with the email address associated with the name that can then be passed to the email submission form.Here is the javascript (the Insert: CODEBOX is not working for me) <script> function enterProducerEmail(producerName){ var Name=producerName; switch (Name) { case "Louise Speelman": return "louis.s@softcom.com"; break; default: return "lewis.h@softcom.com"; } }</script>And where I am getting the hang up is where to run the code in the HTML.I was thinking in the onchange element of the Select/Option statement but I can't seem to find out how to return the correct value to a variable in the form that can then be passed to the email submission.This is probably a simple problem but have been researching it for 2 days through three different forums and not found the answer. Please help.Below is my Select Option statement. (I have truncated some of hte values since it is 15 people long)<select name="producerName" onchange="producerEmail=enterProducerEmail(producerName)"><option value="Louise Speelman">Louise Speelman</option></select><input name="producerEmail" type="text" id="producerEmail" size="45" /> (This could be visible or not to the user)I am using the post methid for form submission with a single form and sinlge submit button.If I can provide any more details I am happy to do so.Thank you very much for any assistance you can provide.

Link to comment
Share on other sites

Instead of doing that, it would be more secure (and require no Javascript) if you used an ID or name for the values in the options, and then figured out on the ASP page which email address that ID corresponded to. If you submitted the email address in the form, a spammer could easily just submit whatever address they want and spam anyone using your server, so you probably want to avoid that. If you just used the person's name or some sort of ID for the dropdown, and had ASP translate that to the person's email address, that would be more secure.

Link to comment
Share on other sites

Instead of doing that, it would be more secure (and require no Javascript) if you used an ID or name for the values in the options, and then figured out on the ASP page which email address that ID corresponded to. If you submitted the email address in the form, a spammer could easily just submit whatever address they want and spam anyone using your server, so you probably want to avoid that. If you just used the person's name or some sort of ID for the dropdown, and had ASP translate that to the person's email address, that would be more secure.
Very good thought. Let me see if I can work it out and then I can pop back in and ask for assistnace if needed. Thank You very mcuh.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...