Solved

3 forms to choose from based on value of variable - javascript

Posted on 2007-11-13
3
797 Views
Last Modified: 2011-09-20
I will try to write out in layman's terms what i am looking for....  if variable = 1, i want to choose html form named "region_west" and send an email to a sales rep that is located in the west, if variable = 2, i want to choose html form named "region_central that will send email to central sales rep, if variable = 3, i want to choose html form named "region_east that will send email to east sales rep

i am defining the variable value correctly and have the forms developed, but need help with the if statement to select the correct form.

.
0
Comment
Question by:cofcmgr
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
nschafer earned 500 total points
ID: 20277083
I'm not 100% sure what you are trying to achive.  I understand what you have asked and I'll answer it first:

if (variable == 1) document.forms["region_west"].submit();
if (variable == 2) document.forms["region_central"].submit();
if (variable == 3) document.forms["region_east"].submit();

or you can use the switch statement:

switch(variable) {
  case 1:
     document.forms["region_west"].submit();
     break;
  case 2:
     document.forms["region_central"].submit();
     break;
  case 3:
     document.forms["region_east"].submit();
     break;
}


But do you really have 3 forms? Do they gather the same information depending on what region the user is from?  What if the user fills out the wrong one?  Wouldn't it be better to have a single form collect the information and then just send the e-mail to the appropriate person based on the selected region?  
Perhaps I misunderstood.

Neal.
0
 

Author Comment

by:cofcmgr
ID: 20284398
The actual input form is the same for each region.  The diffent form for each region consists of hidden objects.  The "hidden" form for one of the regions are .......

form action="/applications/formsprocessor/default.aspx" name="region_west" method="post">
 <input type="hidden" name="to_address"   value="sample@email.com">
 <input type="hidden" name="subject"   value="Subject Line">
 <input type="hidden" name="from_address" value="DoNotReply@mail.com">      
 <input type="hidden" name="redirect"   value="/acquisition/thankyou.html">
 <input type="hidden" name="mail_server"  value="mail.mail.com">
 <input type="hidden" name="body_format"  value="text">
</form>

thanks a million!
0
 
LVL 19

Expert Comment

by:nschafer
ID: 20285945
Glad I could help,
Neal.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now