Hello everyone,
I want to add the "n" number of fields entered by the user in the add_record(). I have used prompt() to take the number from user. But when I alert(result); after onclick(), it gives a message "undefined". Can anyone please tell me the correct way to do this.
Further, I want to add records by using php. How can I get the value entered by the user, so that I can use that value in php script?
Here is the code I have done:
<script language="javascript">
function add_record()
{
var no = prompt("Enter how many records to add","1");
if(no!=null && no!="")
{
num = parseInt(no);
//document.write(num);
//return num;
document.getElementById('ver').value = num;
}
}
</script>
<body>
<form name="ser" method="post">
Name : <input type="text" name="name" /> <br />
Designation : <input type="text" name="design" /> <br />
<input type="hidden" name="ver" id="ver" value="-1"/>
<input type="button" onclick="result = add_record(); alert(result);" value="Add Record" />
<input type="submit" value="Submit" name="submit1" />
</form>
</body>
Thank you.



Reply With Quote

Bookmarks