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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting form fields

Status
Not open for further replies.

soloa

Programmer
Oct 1, 2002
14
0
0
US
Hi, is there a way I can delete a Form field (if it exists) using Javascript so that I can create a new field with the same name (different type) as the deleted field?
 
look into using innerHTML, it won't delete but it will allow you change the firsld type.
 
I don't know exactly what you want to do but here's an implementation of the last comment. This will simply nab the file name and write a new type of input in its place.
[red]
Code:
<form>
<div id=&quot;formfields&quot;>
<input type=&quot;text&quot; name=&quot;tbox&quot;>
</div>
<input type=&quot;button&quot; value=&quot;Change&quot; onclick=&quot;changeInput()&quot;>
</form>

<script type=&quot;text/javascript&quot;>
function changeInput()
{
  var name = document.getElementById(&quot;formfields&quot;).all.tags(&quot;INPUT&quot;).name;
  document.getElementById(&quot;formfields&quot;).innerHTML = '<input type=&quot;button&quot; name=&quot;'+name+'&quot; value=&quot;BLAH&quot;>';
}
</script>
[/red]

God bless,
Ian

 
Thank you for your suggestions. I had an <input type=&quot;text>
and I wanted to make it a <select, which did not work using innerHTML. I did resolve my problem though by making the field a select to begin with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top