?
Solved

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

Posted on 2007-11-13
3
Medium Priority
?
806 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
nschafer earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

762 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