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 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Problem with Id and name as form attributes

    Hi,

    I have a form like this:

    Code:
    <form  method="post" action="/account/register" id="registrationform" name="registration">
    I have two pieces of Java Script. One needs the id tag and the other needs the name. The one that needs name, needs it for something like:

    Code:
    document.registration.countryCode.value
    If I take out the name it complains...

    The problem is that if I am to follow strict XHTML guidelines I should be using either name or id but not both... any ideas?

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,109
    Thanks
    38
    Thanked 498 Times in 492 Posts
    Assuming 'countryCode' is a text element, you can access its value by:

    document.getElementById('countryCode').value

    in place of the 'document.registration.countryCode.value'

    where
    <input type="text" id='countryCode' name='countryCode' value='USA'>


  •  

    Posting Permissions

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