XHTML Strict and Script

Discussion in 'HTML' started by Tom, Nov 15, 2003.

  1. Tom

    Tom Guest

    Hi,

    XHTML depreciates "name" and "target" for FORM. Most javascripts that
    interact with FORM make heavy use of "name" to know which form to interact
    with. You can use ID to 'name' a form, but javascript does not recognize
    "id".

    I have not been able to find any discussions of how to get around these
    obstacles. Does anyone have any websites to review or suggestions?

    Tom
     
    Tom, Nov 15, 2003
    #1
    1. Advertising

  2. Tom wrote:

    > You can use ID to 'name' a form, but javascript does not recognize "id".


    Yes it does, document.getElementById().
     
    Leif K-Brooks, Nov 15, 2003
    #2
    1. Advertising

  3. Tom

    Tom Guest

    "Leif K-Brooks" <> wrote in message
    news:lShtb.854$...
    > Tom wrote:
    >
    > > You can use ID to 'name' a form, but javascript does not recognize "id".

    >
    > Yes it does, document.getElementById().


    OK, here is the code:

    <form id="form3" action="url">
    <select name="pblinks" size="1">
    <option selected value="#">Select the size...</option>
    <option value="url">1.0 L - $19.90</option>
    <option value="url">1.5 L - $29.85</option>
    <option value="url">2.0 L - $39.80</option>
    <option value="url">3.0 L - $59.70</option>
    </select><br />
    <input id="button" type="button" value="Buy Now"
    onclick="window.open(document.getelementbyid().pblinks.options[document.gete
    lementbyid().pblinks.selectedIndex].value);" />
    </form>

    Is this the proper use of the getelementbyid()?

    Thanks for the help...Tom
     
    Tom, Nov 15, 2003
    #3
  4. "Tom" <> wrote:

    > <input id="button" type="button" value="Buy Now"
    >

    onclick="window.open(document.getelementbyid().pblinks.options[document.gete
    > lementbyid().pblinks.selectedIndex].value);" />
    > </form>
    >
    > Is this the proper use of the getelementbyid()?


    No, use:

    document.getElementById('pblinks').

    Also, notice that JavaScript is case-sensitive.
     
    Vjekoslav Begovic, Nov 15, 2003
    #4
  5. Tom

    Kris Guest

    In article <xHitb.10726$Q64.5650@fed1read03>, "Tom" <>
    wrote:

    > <form id="form3" action="url">
    > <select name="pblinks" size="1">
    > <option selected value="#">Select the size...</option>
    > <option value="url">1.0 L - $19.90</option>
    > <option value="url">1.5 L - $29.85</option>
    > <option value="url">2.0 L - $39.80</option>
    > <option value="url">3.0 L - $59.70</option>
    > </select><br />
    > <input id="button" type="button" value="Buy Now"
    > onclick="window.open(document.getelementbyid().pblinks.options[document.gete
    > lementbyid().pblinks.selectedIndex].value);" />
    > </form>
    >
    > Is this the proper use of the getelementbyid()?


    This is improper use of javascript. The form will not work without it
    and that is totally unneccesary.

    <form action="serverSideHandler.php" method="post"
    onsubmit="if(document.getElementById) {
    window.open(document.getElementById('pblinks').selectedIndex.value);
    return false; }">
    <select name="pblinks" id="pblinks" size="1">
    <option selected>Select the size...</option>
    <option value="http://www.textarea51.com/1">1.0 L - $19.90</option>
    <option value="http://www.textarea51.com/2">1.5 L - $29.85</option>
    <option value="http://www.textarea51.com/3">2.0 L - $39.80</option>
    <option value="http://www.textarea51.com/4">3.0 L - $59.70</option>
    </select><br />
    <input type="submit" value="Buy Now" />
    </form>

    serverSideHandler.php:
    <?
    if($pblinks) {
    header("Location: ".$pblinks);
    } else header("Location: ".$HTTP_REFERER);
    ?>

    Something like this. I may have screwed up in one place or the other,
    since I did not test this.

    --
    Kris
    erlands (nl)
     
    Kris, Nov 15, 2003
    #5
  6. Tom:

    > XHTML depreciates "name" and "target" for FORM. Most javascripts that
    > interact with FORM make heavy use of "name" to know which form to interact
    > with. You can use ID to 'name' a form, but javascript does not recognize
    > "id".


    Of course Javascript recognizes "id".

    > I have not been able to find any discussions of how to get around these
    > obstacles.


    In XHTML 1.0 Transitional you can use both "name" and "target" in forms.
    The same goes for HTML 4.01 Transitional.

    "Target" is missing for forms in HTML 4.01 Strict, as well as in XHTML
    1.0 Strict.

    --
    Bertilo Wennergren <> <http://www.bertilow.com>
     
    Bertilo Wennergren, Nov 15, 2003
    #6
  7. >"Tom" <> wrote in message
    news:hHhtb.10723$Q64.4495@fed1read03...
    > with. You can use ID to 'name' a form, but javascript does not recognize
    > "id".


    document.getElementById()
     
    Woolly Mittens, Nov 15, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Woolly Mittens
    Replies:
    11
    Views:
    2,337
    William Tasso
    Jan 2, 2004
  2. Kelwin Delaunay

    img alignment in xhtml strict and css

    Kelwin Delaunay, Apr 17, 2004, in forum: HTML
    Replies:
    4
    Views:
    10,851
    Kelwin Delaunay
    Apr 17, 2004
  3. MWSunshine

    strict xhtml and css

    MWSunshine, Jul 6, 2004, in forum: HTML
    Replies:
    19
    Views:
    845
    Webcastmaker
    Jul 8, 2004
  4. sionvalais
    Replies:
    1
    Views:
    4,471
    Alan J. Flavell
    Sep 14, 2003
  5. John
    Replies:
    1
    Views:
    599
Loading...

Share This Page