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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating form field using document

Status
Not open for further replies.

MikeCole

Programmer
Jul 6, 2000
4
US
I am a new user of javascript, ASP, HTML with MS personal Web server and MS SQL 7.0.&nbsp;&nbsp;I wrote a form data validation function using javascript.&nbsp;&nbsp;It is used by a number of buttons on a form.&nbsp;&nbsp;In order for me to identify the calling origin, I like to update a hidden variable on the calling form.&nbsp;&nbsp;The following are the commands, and it is not working.&nbsp;&nbsp;I would appreicate your help.<br><br>CALLING FORM<br>============<br>...<br>&lt;input type=&quot;hidden&quot; name=&quot;hiddenfield&quot;&gt;<br>&lt;input type=&quot;button&quot; name=&quot;cmdnew&quot; value=&quot;New&quot; onclick=&quot;validateform(thisform,&quot;New&quot;)&gt;<br>&lt;input type=&quot;button&quot; name=&quot;cmdfind&quot; value=&quot;Find&quot; onclick=&quot;validateform(thisform,&quot;Find&quot;)&gt;&nbsp;&nbsp;<br>...<br><br>FUNCTION<br>========<br>function validateform(thisform,thiscmd) {<br>...<br>document.thisform.hiddenfield.value = thiscmd<br>document.thisform.submit()<br>....<br>}<br><br><br><br><br><br>
 
Could you show me the rest of the page. Im a little confused. I guess give me a link to it instead of posting it here if you can.<br><br>If the button is treated as <input type=button> it should have a this.form property. So if in your function call, you say validate(this.form), you can find out the name of the form the button is in.
 
Dear Mike,<br><br>&gt; onclick=&quot;validateform(thisform,&quot;New&quot;)&gt;<br><br>That won't work at all, your quote characters are messed up. You need something like this:<br><br>onclick=&quot;validateform('form1','New')&quot;<br><br>Then:<br><br>****<br>function validateform(thisform,thiscmd) {<br>...<br>document.thisform.hiddenfield.value = thiscmd<br>*****<br><br>The parameter 'thisform' is a string containing the form name so you need to do something like this to get the form variable object that you want to set the value of:<br><br>var oEle = eval(&quot;document.&quot; + thisform + &quot;.hiddenfield&quot;);<br>oEle.value = thiscmd;<br><br>Hope this helps<br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top