Jump to content

onclick removeChild doenst work as expected? have to click twice for it to work


mac007

Recommended Posts

Hi all:

 

I am pretty new at this javascipt stuff; so I have this simple script where the "onclick removeChild" doenst work as expected? I have to click twice for it to delete each field; also, how can I make it so when clicking the "remove text field" button, it only deletes, let's say text field "one", and not keep on deleting form elements??

 

Thanks!

 


<html>
<head>
</head>
<body>
<script language="JavaScript">

function function2() {
    myList.removeChild(myList.firstChild);
}
</script>

<input type="button" value="Remove Text field!" onClick="function2();" >
<form id="myList" action="" method="get">
<input name="one" type="text" id="one">
<input name="two" type="text" id="two">
<input name="" type="submit">
</form>


<br>
<br>
output text: <?php echo $_GET["one"]. ", " . $_GET["two"]; ?>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.