Solved

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

Posted on 2007-11-13
3
799 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

803 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