ilugd
Beware of the innocent
i have this webpage in which i am trying to dynamically add a text input box. I haven't got as far as to see if what i am trying to do is happening. I am still stuck at getting my click button to add the input box. I don't know what I am doing wrong.
The addtextbox function is supposed to add the element.
On clicking on the button Click, the function is supposed to be called. I added the alert call to check if the function is called.
The addtextbox function is supposed to add the element.
On clicking on the button Click, the function is supposed to be called. I added the alert call to check if the function is called.
Code:
<html>
<head>
<title></title>
</head>
<body>
<script language="javascript">
function addtextbox(){
alert("ok, function called");
var frm=document.forms[0];
var newtxt=document.createElement('input');
newtxt.setAttribute('type','text');
newtxt.setAttribute('value','new box');
newtxt.setAttribute('value','formvalue[]');
frm.appendChild(newtxt);
}
;
</script>
<form action="index.php" method="get">
<input name="formvalue[]" type=text value="default value"/>
<input type="button" value="Click to add box" onclick()="addtextbox();"/>
<input type="submit" />
</form>
</body>
</html>