Forum Moderators: open

Message Too Old, No Replies

Remove element

Not just hide

         

Readie

4:18 pm on Apr 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been tasked with creating the core aspects of a job site, and I've written a script to add/remove form elements from the search form based off their ID (i.e. I click a [-] next to a form input, the input is removed).

Now, I wan't to remove the element so that it doesn't post whatever value was previously contained before the [-] was clicked, so document.getElementById("something").style.display = "none"; won't cut it here.

An alternative would either be something that completely removes that form element, or something that stops it from posting so I can then hide it.

Unfortunatley 20 minutes of Googling hasn't returned what I'm looking for.

Could anyone point me in the right direction here please?

Readie

4:36 pm on Apr 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bleh, should of thought of this sooner.

document.getElementById("something").disabled = true;
document.getElementById("something").style.display = "none";

Has the effect I'm after :)

coopster

7:54 pm on Apr 29, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That's how I handle it :)

rocknbil

3:51 am on Apr 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or if you want to completely nuke it,

<p id="short-halflife"><label for="something">Something:</label> <input type="text" name="something" id="something"></p>

document.getElementById("short-halflife").innerHTML='';

<poof>

Readie

10:43 am on Apr 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I should of that too. Although with the vertical spacing <p> provides I'd probably have to go with <span>.

Anyway, can't be bothered changing the JavaScript now. It works, I hate doing JS, I'm not touching this script again :D

Thanks for the idea though, I'll remember that.