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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing the name attribute in a form

    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.
    Code:
    <form action="sign.php" name="tagger" method="get" onsubmit="javascript: tagSubmit();">
    the javascript that goes with it is
    Code:
    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...

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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();

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Awesome! thanks

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

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