...

View Full Version : Changing the name attribute in a form



ToeBee
08-12-2005, 08:38 PM
Hi everyone. I really don't know much about javascript so I need a little help. I am trying to alter a php shoutbox script to conform to my XHTML strict site. I have been succesful at making the script pass validation except for one error.

The error is cause by the name attribute in the form.

<form action="sign.php" name="tagger" method="get" onsubmit="javascript: tagSubmit();"> the javascript that goes with it is

function tagSubmit() {
document.tagger.message.focus();
document.tagger.comment.value = document.tagger.message.value;
document.tagger.message.value = '';
}

XHTML strict will not allow a name attribute in the form just in the inputs. My question is, Is there a way to change the name attribute to somthing else that will pass as XHTML strict? Somthing like id="tagger".

Or possibly move the name attribute to a hidden input? Any ideas? Any help would be apperciated...

nikkiH
08-12-2005, 09:34 PM
Yes, change to the ID attribute, then change the script to use
document.getElementById("tagger")
instead of
document.tagger

i.e.
document.tagger.message.focus();
becomes
document.getElementById("tagger").elements("message").focus();

ToeBee
08-12-2005, 09:46 PM
Awesome! thanks :)

Willy Duitt
08-12-2005, 10:27 PM
Answered here as well: http://www.webdeveloper.com/forum/showthread.php?t=75775



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum