...

View Full Version : Problem with Id and name as form attributes



eeijlar
10-11-2008, 06:06 PM
Hi,

I have a form like this:


<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:


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?

jmrker
10-12-2008, 02:19 AM
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'>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum