Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  39] [ 5]  / answers: 1 / hits: 85403  / 13 Years ago, thu, september 15, 2011, 12:00:00

Lets say I have a form as below. How do I pass the value in the textbox named configname to the onclick function handler??



<form id=loadconfigform>
Config Name: <input type=text name=configname />
<input type=button value=Submit onclick=onLoadConfigPress(configname) />
</form>

More From » html

 Answers
7

Give an id to input field:



<input type=text id=configname name=configname />


Now modify click handler as follows:



<input type=button value=Submit 
onclick=onLoadConfigPress(document.getElementById('configname').value) />


Or if you have only one form on that page, you could also use forms array:



<input type=button value=Submit 
onclick=onLoadConfigPress(document.forms[0].configname.value) />

[#90096] Tuesday, September 13, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaidyn

Total Points: 633
Total Questions: 102
Total Answers: 100

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
2 Years ago
;