Suppose I have the following HTML code, how can I pass the user’s input to execute(str) JavaScript function as an argument?
<body> <input name='textbox1' type='text' /> <input name='buttonExecute' onclick='execute(//send the user's input in textbox1 to this function//)' type='button' value='Execute' /> </body>
You could either access the element’s value by its name:
So:
Or you assign an ID to the element that then identifies it and you can access it with
getElementById: