...

View Full Version : Remove NAME attribute of input element?



Marvado
07-28-2006, 05:04 PM
Hi,

how do I remove the NAME attribute of an INPUT element using javascript.
Ex: <input type="text" name="password">

To: <input type="text">

thanks,
pedro.

Bill Posters
07-28-2006, 05:27 PM
Option 1:

document.getElementsByName('password')[0].removeAttribute('name');

Option 2:

document.getElementsByName('password')[0].name='';

I'm curious to know why would you want to do that.

Marvado
07-28-2006, 05:40 PM
Thanks Bills,
works very nice

I have to send a form without these input names. Basically I have several input name="" with the same name, and want to contatenate the values in one single hidden input field, and eliminate the others. Work stuff! :)

thanks again.

Kor
07-30-2006, 08:44 AM
You might have also disabled the form's elements.

Kor
07-30-2006, 08:47 AM
On the other hand, if your server-side application is php, you might have kept the same names, but noted as php arrays:

name="myname[]"

Kravvitz
07-30-2006, 04:53 PM
Keep in mind that some Internet users use a browser that doesn't have JavaScript enabled. (http://www.thecounter.com/stats/2006/June/javas.php)

The Importance of Degrading Gracefully (http://weblog.burningbird.net/archives/2005/03/25/the-importance-of-degrading-gracefully/)
Perpetuating the myths of JavaScript degradation. (http://domscripting.com/blog/display.php/25)

I've heard that at least one older browser, I think it may have been Opera 6, wrongly submits the name/value pair for disabled form elements.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum