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>
Simply call it using its name. I'd recommend using ID though.
This won't work if you have other elements with the same name, so do use ID like the other answers have suggested.
Give an
id
to input field:Now modify click handler as follows:
Or if you have only one form on that page, you could also use
forms
array: