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

hidden values in text boxes

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
Is it possible to have a hidden value attached to a text box in a form so that if nothing is inputted by the user into that textbox the value is for example: "not specified" without the user knowing?
 
Yes. onSubmit you can call a function that checks the value of your text box. if the value is nothing, you can assign the value of something, then proceed in sending the form info. here's half pseudo, half real code (in other words i've been working in other languages recently and not JS, check syntax).

Function checkTextValue(TextName){
if document.forms[Form1].elements[TextName].value == "" {document.forms[Form1].elements[TextName].value == "Not Specified";
}
}

<form name=&quot;Form1&quot; method=&quot;post&quot; action=&quot;scripts.asp&quot; onSubmit=&quot;checkTextValue(NameOfTextBox)&quot;>
<input type=&quot;text&quot; name=&quot;NameOfTextBox&quot; value=&quot;&quot;>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;>
</form>

Try that. I may have left something out like a return true; at the end.
Hope that gives you something to start with...
Thessa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top