By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,078 Members | 1,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,078 IT Pros & Developers. It's quick & easy.

How to pass a textbox value to both the forms?

P: 79
Hi,

I have one common text box to get email id.
I have 2 forms and both form action connects to different programs.

I want to use this textbox value(i.e email id) only for both the forms.
How can i get the value of text box and use it in both forms?

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script>
  4. function call()
  5. {
  6. var mf=document.getElementById("emailid");
  7. eid=mf.value;
  8. //alert(eid);
  9. return (eid);
  10. }
  11. </script>
  12. <p align="center">Enter your email id for results:<input type="text" name="email" id="emailid" size="20">
  13. <form name="main" action="/cgi-bin/pubmed_abstract/queue.cgi" method="get" onSubmit="return call()"> (form 1)
  14. </td>
  15. </table>
  16. <br>
  17. <table cellpadding="10" style="border: 1px solid rgb(0, 0, 0);" bgcolor="#BDEDFF" width="694">
  18. <tr>
  19. <td><font face="Arial" size="2"><b>WORDS</b></font></td>
  20. </tr>
  21. <tr>
  22. <td><font face="Arial" size="2"><b>All of these</b></font><br></td>
  23. <td><input type="text" name="query" size="80">
  24. </td>
  25. </tr>
  26. </table>
  27. <input type="submit" value="submit"> (when submit button is pressed the email value has to be passed to queue.cgi)
  28. <input type="reset"  value="RESET">
  29. </form>
  30. <b>Advanced search (Using Boolean Operators)</b>
  31. <br>
  32. <form name="f2" action="/cgi-bin/pubmed_abstract/advance.cgi" method="get" onSubmit="return call1()"> (form 2)
  33. some code here....
  34. <input type="submit" value="submit"> (when submit button is pressed the email values has to be passed to advance.cgi)
  35. <input type="reset"  value="RESET">
  36.  
I tried using functions that didn't work!!!
The value of textbox has to be used by both forms?
How to get the value of textbox for 2 forms and use it?

With regards
Archana
Jul 5 '08 #1
Share this Question
Share on Google+
2 Replies


hsriat
Expert 100+
P: 1,654
Either you can use the same form, but different submit buttons to reach the different scripts.

Or keep one of the input as hidden, and copy the value from the email input to the hidden one with JavaScript.
Jul 5 '08 #2

P: 79
Either you can use the same form, but different submit buttons to reach the different scripts.

Or keep one of the input as hidden, and copy the value from the email input to the hidden one with JavaScript.

Hi,

can u give an example?

Actually i don't know how to include the code?
Jul 8 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.