Results 1 to 8 of 8

Thread: submit button uses Onclick but does not validate under w3.org

  1. #1
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default submit button uses Onclick but does not validate under w3.org

    Hi

    I am using a form which send users to different url when you select an option. Below is my form and the javascript used.
    Code:
    <form name="Iccy" action="">
    Sort By: <select name="blah" class="small">
    <option value="http://www.mysite.com/jjskkhkjsl.html">Page1</option>
    <option value="http://www.mysite.com/blah.html">Page 2</option>
    </select>
    <script language="javascript">
    <!--
    function go() {
    	location=document.Iccy.blah.
    	options[document.Iccy.blah.selectedIndex].value
    }
    //-->
    </script>
    <input type="button" name="test" value="Go!" onClick="go()">
    </form>
    Now the problem is that when I validate my page using the w3.org it shows error stating that the onClick="go()" used is invalid and cannot be used with the doc type. I do not want to change my doctype or anything else and I want my page to validate since all my pages are validated nicely.
    Can someone please give me another alternative to my approach. Any other way of sending user to that url but within a form and also be validate with XHTML1.0

    Thanks

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    language has been depreciated...
    use
    Code:
    <script type="text/javascript">
    ___ your code _____
    also the variable "go" is used by the language itself so you need to create a new variable you can do something like
    Code:
    function goPlace()

  3. #3
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks alot buddy

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    also the variable "go" is used by the language itself so you need to create a new variable you can do something like
    I don't think if you override a built-in function with your own it show any error. But it is wise to avoid a built-in function name as you own function name.

    Code:
    <input type="button" name="test" value="Go!" onClick="go()">
    You need to put the contents that you've furnished inside the body within the correct container elements like <p>

    Moreover you haven't provided the Doctype you've used in your case.

  5. #5
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The actual problem was with onClick being in capital letter C. Changing that into onclick gave no errors while validating.

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you must be trying to validate it with xhtml.... I would suggest that you do not use the xhtml doctype as it is not supported by IE, and thus you cannot reap the full benefits that it provides, accurately on a consistent basis

  7. #7
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    well so far my pages have been validated nicely by XHTML 1.0 doc type. And my pages display fine too on every browser. I am making my website cross browser compatible. So if you saying IE does not support XHTML I would like to know in hat situation? Since everything is fine and validating.

    Thanks

  8. #8
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    whether it validates or not, IE doesnt support it. Read this article
    http://www.w3.org/2000/07/8378/xhtml...pes/MSIE6.0SP2

Bookmarks

Posting Permissions

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