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!

Accessing the value of an Input Text?

Status
Not open for further replies.

camilo

MIS
May 16, 2000
10
MX
I'm building a webpage and using &lt;input text&gt; and &lt;select&gt; to show some data. I'm also using cold fusion but have a problem I wan't to pass the data from the text field or the list box to a CF variable in the same webpage is there anyway just to access the value and what is the instruction to do that. I'm not using forms, will I need to???<br>Example of my problem below:<br><br>&lt;!-- samefile.html --&gt;<br>&lt;cf set cad=&quot;&quot;&gt;<br>&lt;input type=&quot;text&quot; name=&quot;Data&quot; size=&quot;10&quot; maxlength=&quot;10&quot; message=&quot;Data&quot;&gt;<br><br>How do I pass the value from input to cad(e.g cad=input.text) <br>
 
You will definitely need to use a form, since Netscape won't show controls without a form.<br><br>This seemed to work for me in IE5, I hope it would work for you:<br><br>1) Put a [dummy] form round your controls:<br><br>&lt;FORM NAME=&quot;DummyForm&quot; METHOD=&quot;POST&quot; ACTION=&quot;dummy.htm&quot;&gt;<br>...<br>&lt;/FORM&gt;<br><br>Don't worry about the action, the form never gets submitted.<br><br>2) To access the text box's value from within the same page, without submitting:<br><br>document.forms[&quot;DummyForm&quot;].Data.value<br><br>where the name in the forms[] array matches your form's given name and Data is the name of your text box as you named it...<br><br>(This was JavaScript, in case you didn't realise - don't use VBScript, Netscape ignores it).<br><br>
 
um, JTeagle is right, you need a form to access the current information in the textbox. Also, the format for accessing the current information in a textbox is: (using the form example from above) document.DummyForm.Data.<b>value</b>, not document.DummyForm.Data.<b>text</b><br><br>you could also use:<br><br>document.forms[&quot;DummyForm&quot;].Data.value, but document.DummyForm.Data.value is shorter. <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Can you be sure Netscape supports the control name as a direct object, rather than an entry into an array of objects?
 
That method has always worked for me, and thats the way that I learned it at <A HREF=" TARGET="_new"> <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top