Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove NAME attribute of input element?

    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.

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Option 1:
    Code:
    document.getElementsByName('password')[0].removeAttribute('name');
    Option 2:
    Code:
    document.getElementsByName('password')[0].name='';
    I'm curious to know why would you want to do that.

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    You might have also disabled the form's elements.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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[]"
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Keep in mind that some Internet users use a browser that doesn't have JavaScript enabled.

    The Importance of Degrading Gracefully
    Perpetuating the myths of JavaScript degradation.

    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.
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •