Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete a form element

Status
Not open for further replies.

berkshirea

Technical User
Mar 22, 2009
97
GB
hi guys, can you give me some tips please. i've been searching around but still no luck. i'd like a script that would delete/remove a textfield by clicking the button/text opposite the textfield.

something like below:

thisIsMyTextfield -- clickThisToRemoveTextfield
thisIsMyTextfield -- clickThisToRemoveTextfield
thisIsMyTextfield -- clickThisToRemoveTextfield
thisIsMyTextfield -- clickThisToRemoveTextfield
thisIsMyTextfield -- clickThisToRemoveTextfield

please note that all the textfields are of same name.

thanks for any inputs.




 
Delete, as in completely remove, or maybe just hide? Or even disable?

I would start by looking at the removeChild() function.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
hi vacunita,

it's a delete as in completeley remove as selected text field.
 
hi guys,

i found a code and did a bit of amending and it worked!

Code:
<html>
<head>
<script type="text/javascript">
function deleteRow(r)
{
var i=r.parentNode.parentNode.rowIndex;
document.getElementById('myTable').deleteRow(i);
}
</script>
</head>
<body>

<table id="myTable" border="1">
<tr>
  <td>Row 1</td>
  <td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
</tr>
<tr>
  <td>Row 2</td>
  <td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
</tr>
<tr>
  <td>Row 3</td>
  <td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
</tr>
</table>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top