Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to filter by key press ? 6 55
Non-Resizable Pharagraph 2 18
jQuery Datatables.js Selecting a Row to get ID 5 36
Boolean 13 22
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'…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

749 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