Here is my form:
<form id="aform">
<input type="text" id="rollno" name="rollno">
<input type="button" value="show result" onclick="showResultFunction ('someurl.com','divtodisplayresult');>
</form>
Question: Can I pass rollno entered in the function onclick as parameter? Like:
onclick="showResultFunction ('someurl.com','divtodisplayresult',rollno);
试着做:
onclick="showResultFunction ('someurl.com','divtodisplayresult', document.getElementById('rollno').value);
Alternatively, in the Javascript function itself, you can access the rollno value in code:
function showResultFunction(url, div)
{
var rollno = document.getElementById("rollno");
alert(rollno.value);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.