Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I have a question. Can I

Status
Not open for further replies.

WannaLearn

Programmer
Jul 10, 2001
210
US
Hello, I have a question. Can I pass a variable from one form to another form, on the same page?
What I want to do is, on form have the user fill out some general information then when they click a button they go to the bottom where they enter their contact info and submit the form. BUT each form is sent to a diff. email address. What I want to do is pass the 'email address' from one form to the next, so that the general information AND the contact information get emailed. Is that possible?
Thanks.
This is my code so far:
Code:
<HTML>
<HEAD>

<script>
function goThere() {
  if(document.form1.select1.options[0].selected == true) {
    alert(&quot;Select Something&quot;);
    return false;
  }
  else {
    window.location.href=document.form1.select1.options[document.form1.select1.selectedIndex].value
  }
}
</script>
</HEAD>

<BODY BGCOLOR=&quot;#ffffff&quot;>
<CENTER>
  <br>
  <table width=&quot;700&quot; border=&quot;0&quot; align=&quot;center&quot;>
    <tr valign=&quot;top&quot;> 
      <td>
        <center>
          <table cellpadding=&quot;2&quot; align=&quot;Center&quot;>
            <tr valign=&quot;Top&quot;> 
              <td> <form name=&quot;form1&quot;>
                  <select name=&quot;select1&quot;>
                    <option value=&quot;&quot;>Please Select One of the Following:</option>
                    <option value=&quot;#Section1&quot;>Section 1</option>
                    <option value=&quot;#Section2&quot;>Section 2</option>
                    <option value=&quot;#Section1&quot;>Section 3</option>
                  </select>
                  <input type=&quot;button&quot; value=&quot;Take me there&quot; onClick=&quot;return goThere();&quot;>
                </form></td>
            </tr>
          </table>
          <p> </p>
          <p> </p>
          <p> </p>
          <p> </p>
          <p> </p>
        </center>
        <hr>
        <table width=&quot;700&quot; align=&quot;center&quot;>
  <tr>
    <td>
<form method=&quot;get&quot; action=&quot;&quot;>
                <p> 
          <a name=&quot;Section1&quot;></a><hr>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr> 
                    <td width=&quot;72%&quot;><font size=&quot;2&quot; color=&quot;#ff0000&quot;><b>SECTION 
                      1 :</b></font><font size=&quot;2&quot; color=&quot;004080&quot;>  For this 
                      area, please enter the requested information.</font></td>
                    <td width=&quot;28%&quot;> </td>
            </tr>
          </table>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr valign=&quot;middle&quot;> 
                    <td><font size=&quot;2&quot;><b>My question is: </b></font> <table width=&quot;90%&quot; cellpadding=&quot;2&quot;>
                        <tr valign=&quot;middle&quot;> 
                          <td width=&quot;56%&quot;><textarea name=&quot;section 1 txt&quot; cols=&quot;30&quot;></textarea> 
                          </td>
                          <td width=&quot;1%&quot;> </td>
                          <td width=&quot;32%&quot;><font size=&quot;2&quot;><b><a href=&quot;#organization&quot;>continue</a></b></font></td>
                          <td width=&quot;11%&quot;> </td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
</form>
              <p>
              <p> 
              <form method=&quot;GET&quot; action=&quot;&quot;>
          <a name=&quot;Section2&quot;></a><hr>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr > 
                    <td width=&quot;69%&quot;><font face=&quot;ARIAL, TAHOMA, VERDANA&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;><b>SECTION 
                      2 :</b></font><font face=&quot;ARIAL, TAHOMA, VERDANA&quot; size=&quot;2&quot; color=&quot;004080&quot;> 
                       For this area, please enter the requested information.</font></td>
                    <td width=&quot;31%&quot;></td>
                  </tr>
                </table>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr> 
                    <td width=&quot;575&quot;><font size=&quot;2&quot;><b>My question is: </b></font><BR> <table width=&quot;90%&quot; cellpadding=&quot;2&quot;>
                        <tr valign=&quot;middle&quot;> 
                          <td width=&quot;56%&quot;><textarea name=&quot;section 2 txt&quot; cols=&quot;30&quot; id=&quot;section 2 txt&quot;></textarea> 
                          </td>
                          <td width=&quot;1%&quot;> </td>
                          <td width=&quot;39%&quot;><font size=&quot;2&quot;><b><a href=&quot;#organization&quot;>continue</a></b></font></td>
                          <td width=&quot;4%&quot;> </td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
</form>
<p>
<p>
<form method=&quot;GET&quot; action=&quot;&quot;>
                <font size=&quot;2&quot; color=&quot;#ff0000&quot;><b><a name=&quot;Section3&quot;></a></b></font> 
                <hr>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr > 
                    <td width=&quot;69%&quot;><font size=&quot;2&quot; color=&quot;#ff0000&quot;><b>SECTION 
                      3 :</b></font><font size=&quot;2&quot;>  For this area, please 
                      enter the requested information.</font></td>
                    <td width=&quot;31%&quot;></td>
                  </tr>
                </table>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr> 
                    <td><font size=&quot;2&quot;><b>My question is: <br>
                      </b></font> <table width=&quot;90%&quot; cellpadding=&quot;2&quot;>
                        <tr valign=&quot;middle&quot;> 
                          <td width=&quot;56%&quot;><textarea name=&quot;section 3 txt&quot; cols=&quot;30&quot; id=&quot;section 3 txt&quot;></textarea> 
                          </td>
                          <td width=&quot;1%&quot;> </td>
                          <td width=&quot;38%&quot;><font size=&quot;2&quot;><b><a href=&quot;#organization&quot;>continue</a></b></font></td>
                          <td width=&quot;5%&quot;> </td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
              </form>
<p>
<p>

              <form method=&quot;GET&quot; action=&quot;&quot;>
                <p> <br>
                <p>  
                <hr>
          <br>
                <a name=&quot;organization&quot;></a><font color=&quot;ff0000&quot; size=&quot;2&quot;><b>CONTINUE:</b></font><br>
          <br>
                <table>
                  <tr> 
                    <td width=175 align=RIGHT></td>
                    <td></td>
                  </tr>
                  <tr valign=&quot;middle&quot;> 
                    <td width=175 align=RIGHT><font face=&quot;ARIAL, TAHOMA, VERDANA&quot;
        size=&quot;1&quot;><b>Your Name:</b></font></td>
                    <td width=300> <input type=&quot;text&quot; name=&quot;YOUR NAME&quot; maxlength=&quot;30&quot; size=&quot;30&quot;> 
                    </td>
                  </tr>
                  <tr valign=&quot;middle&quot;> 
                    <td width=175 align=&quot;RIGHT&quot;><font face=&quot;ARIAL, TAHOMA, VERDANA&quot; size=&quot;1&quot;><b>Your 
                      Number:</b></font></td>
                    <td width=300> <input type=&quot;text&quot; name=&quot;YOUR TELEPHONE NUMBER&quot; maxlength=&quot;14&quot; size=&quot;14&quot;> 
                    </td>
                  </tr>
                </table>
                <br>
                  <input type=&quot;submit&quot; value=&quot;Submit Your Question&quot; name=&quot;submit&quot;>
                  <input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;reset&quot;>
              </form>
    </td>
  </tr>
</table>  
      </td>
    </tr>
  </table>
</CENTER>
</BODY>
</HTML>

By the way, I will using cgi to email the forms. Thanks.
 
I think you may be trying to overcomplicate it a little.

why not just have one form and change the action of that form?

<script type=&quot;text/javascript&quot;>
<!--
function SubmitIt(action)
{
document.forms[0].action = action
document.forms[0].submit()
}
//-->
</script>



 
Hi simonchristieis. Thanks for responding. So how I can incorporate my function goThere() with your SubmitIt(action)?
I have to use the function goThere() (boss wants that feature).
Thanks.
 
sommat like this

<select name=&quot;select1&quot;>
<option strEmail=&quot;me@me.com&quot; value=&quot;&quot;>Please Select One of the Following:</option>
<option strEmail=&quot;you@you.com&quot; value=&quot;#Section1&quot;>Section 1</option>
<option strEmail=&quot;them@them.com&quot; value=&quot;#Section2&quot;>Section 2</option>
<option strEmail=&quot;those@those.com&quot; value=&quot;#Section1&quot;>Section 3</option>
</select>

<input type=&quot;hidden&quot; value=&quot;&quot; name=&quot;strEmail&quot;>



function SubmitIt(action)
{
if(document.forms[0].select1.options[0].selected == true) {
alert(&quot;Select Sommat&quot;);
}else{
document.forms[0].strEmail.value = document.forms[0].select1.options[document.forms[0].select1.selectedIndex].getAttribute(&quot;strEmail&quot;)

window.location.href=document.forms[0].select1.options[document.form1.select1.selectedIndex].value;

}}

if you are using cgi to send the form - then you dont need to change the action of the form (send it somewhere else), you just need a hidden field to hold the email data. You will need to pick up the tsrEmail field in the cgi code.

hope this helps

simon



 
Hello Simon. I'm having some problems setting up your method within my code. This is what I did, but it doesn't seem to email right.

Code:
<HTML>
<HEAD>

<script>
function SubmitIt(action) {
  if(document.forms[0].select1.options[0].selected == true) {
    alert(&quot;Select Sommat&quot;);
  }
  else {
    document.forms[0].strEmail.value = document.forms[0].select1.options[document.forms[0].select1.selectedIndex].getAttribute(&quot;strEmail&quot;)
    window.location.href=document.forms[0].select1.options[document.form1.select1.selectedIndex].value;
  }
}
</script>

</HEAD>

<BODY BGCOLOR=&quot;#ffffff&quot;>
<CENTER>
  <br>
  <table width=&quot;700&quot; border=&quot;0&quot; align=&quot;center&quot;>
    <tr valign=&quot;top&quot;> 
      <td>
        <center>
          <table cellpadding=&quot;2&quot; align=&quot;Center&quot;>
            <tr valign=&quot;Top&quot;> 
              <td> 
				<form name=&quot;form1&quot;>
      			<select name=&quot;select1&quot;>
        		  <option value=&quot;&quot;>Please Select One of the Following:</option>
        		  <option strEmail=&quot;mailto:email12@isp.com&quot; value==&quot;#Section1&quot;>Section 1</option>
	    		  <option strEmail=&quot;mailto:email123@isp.com&quot; value=&quot;#Section2&quot;>Section 2</option>
				  <option strEmail=&quot;mailto:email1234@isp.com&quot; value=&quot;#Section3&quot;>Section 3</option>
	  			</select>
        		  <input type=&quot;hidden&quot; value=&quot;&quot; name=&quot;strEmail&quot;>
                  <input type=&quot;button&quot; value=&quot;Take me there&quot; onClick=&quot;return SubmitIt();&quot;>
                </form></td>
            </tr>
          </table>
          <p> </p>
          <p> </p>
          <p> </p>
          <p> </p>
          <p> </p>
        </center>
        <hr>
        <table width=&quot;700&quot; align=&quot;center&quot;>
  <tr>
    <td>
<form method=&quot;get&quot; action=&quot;&quot;>
                <p> 
          <a name=&quot;Section1&quot;></a><hr>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr> 
                    <td width=&quot;72%&quot;><font size=&quot;2&quot; color=&quot;#ff0000&quot;><b>SECTION 
                      1 :</b></font><font size=&quot;2&quot; color=&quot;004080&quot;>  For this 
                      area, please enter the requested information.</font></td>
                    <td width=&quot;28%&quot;> </td>
            </tr>
          </table>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr valign=&quot;middle&quot;> 
                    <td><font size=&quot;2&quot;><b>My question is: </b></font> <table width=&quot;90%&quot; cellpadding=&quot;2&quot;>
                        <tr valign=&quot;middle&quot;> 
                          <td width=&quot;56%&quot;><textarea name=&quot;section 1 txt&quot; cols=&quot;30&quot;></textarea> 
                          </td>
                          <td width=&quot;1%&quot;> </td>
                          <td width=&quot;32%&quot;><font size=&quot;2&quot;><b><a href=&quot;#organization&quot;>continue</a></b></font></td>
                          <td width=&quot;11%&quot;> </td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
</form>
              <p>
              <p><br>
              <p> 
              <p>  
              <form method=&quot;GET&quot; action=&quot;&quot;>
          <a name=&quot;Section2&quot;></a><hr>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr > 
                    <td width=&quot;69%&quot;><font face=&quot;ARIAL, TAHOMA, VERDANA&quot; size=&quot;2&quot; color=&quot;#ff0000&quot;><b>SECTION 
                      2 :</b></font><font face=&quot;ARIAL, TAHOMA, VERDANA&quot; size=&quot;2&quot; color=&quot;004080&quot;> 
                       For this area, please enter the requested information.</font></td>
                    <td width=&quot;31%&quot;></td>
                  </tr>
                </table>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr> 
                    <td width=&quot;575&quot;><font size=&quot;2&quot;><b>My question is: </b></font><BR> <table width=&quot;90%&quot; cellpadding=&quot;2&quot;>
                        <tr valign=&quot;middle&quot;> 
                          <td width=&quot;56%&quot;><textarea name=&quot;section 2 txt&quot; cols=&quot;30&quot; id=&quot;section 2 txt&quot;></textarea> 
                          </td>
                          <td width=&quot;1%&quot;> </td>
                          <td width=&quot;39%&quot;><font size=&quot;2&quot;><b><a href=&quot;#organization&quot;>continue</a></b></font></td>
                          <td width=&quot;4%&quot;> </td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
</form>
<p>
              <p>
              <p>
              <p>
              <p>
              <p>
              <p> 
              <form method=&quot;GET&quot; action=&quot;&quot;>
                <font size=&quot;2&quot; color=&quot;#ff0000&quot;><b><a name=&quot;Section3&quot;></a></b></font> 
                <hr>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr > 
                    <td width=&quot;69%&quot;><font size=&quot;2&quot; color=&quot;#ff0000&quot;><b>SECTION 
                      3 :</b></font><font size=&quot;2&quot;>  For this area, please 
                      enter the requested information.</font></td>
                    <td width=&quot;31%&quot;></td>
                  </tr>
                </table>
                <table width=&quot;100%&quot; cellpadding=&quot;2&quot;>
                  <tr> 
                    <td><font size=&quot;2&quot;><b>My question is: <br>
                      </b></font> <table width=&quot;90%&quot; cellpadding=&quot;2&quot;>
                        <tr valign=&quot;middle&quot;> 
                          <td width=&quot;56%&quot;><textarea name=&quot;section 3 txt&quot; cols=&quot;30&quot; id=&quot;section 3 txt&quot;></textarea> 
                          </td>
                          <td width=&quot;1%&quot;> </td>
                          <td width=&quot;38%&quot;><font size=&quot;2&quot;><b><a href=&quot;#organization&quot;>continue</a></b></font></td>
                          <td width=&quot;5%&quot;> </td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
              </form>
<p>
<p>

              <form method=&quot;GET&quot; action=&quot;&quot;>
                <p>  
                <p> 
                <p> 
                <p> 
                <p><br>
                <p>  
                <hr>
          <br>
                <a name=&quot;organization&quot;></a><font color=&quot;ff0000&quot; size=&quot;2&quot;><b>CONTINUE:</b></font><br>
          <br>
                <table>
                  <tr> 
                    <td width=175 align=RIGHT></td>
                    <td></td>
                  </tr>
                  <tr valign=&quot;middle&quot;> 
                    <td width=175 align=RIGHT><font face=&quot;ARIAL, TAHOMA, VERDANA&quot;
	    size=&quot;1&quot;><b>Your Name:</b></font></td>
                    <td width=300> <input type=&quot;text&quot; name=&quot;YOUR NAME&quot; maxlength=&quot;30&quot; size=&quot;30&quot;> 
                    </td>
                  </tr>
                  <tr valign=&quot;middle&quot;> 
                    <td width=175 align=&quot;RIGHT&quot;><font face=&quot;ARIAL, TAHOMA, VERDANA&quot; size=&quot;1&quot;><b>Your 
                      Number:</b></font></td>
                    <td width=300> <input type=&quot;text&quot; name=&quot;YOUR TELEPHONE NUMBER&quot; maxlength=&quot;14&quot; size=&quot;14&quot;> 
                    </td>
                  </tr>
                </table>
                <br>
                  <input type=&quot;submit&quot; value=&quot;Submit Your Question&quot; name=&quot;submit&quot;>
                  <input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;reset&quot;>
              </form>
    </td>
  </tr>
</table>  
      </td>
    </tr>
  </table>
</CENTER>
</BODY>
</HTML>

How can I get the form to be e-mailed to right email address depending on what section the user selected? The info. from the selected section AND the info from the CONTINUE has to be emailed.
I know this sounds too much, but that is what the boss wants, and I don't want to argue with him.
Is that even doable? For testing purposes i'm using the &quot;mailto:&quot; tag.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top