Forms tag question

Discussion in 'Javascript' started by Dave F., Oct 6, 2003.

  1. Dave F.

    Dave F. Guest

    Is it possible to access the value of a radio button or change a radio
    button to enabled/disabled without using the forms tags<FORM></FORM>? In
    other words is the forms tag required for these actions?

    Thanks,
    Dave F.
    Dave F., Oct 6, 2003
    #1
    1. Advertising

  2. In article <n6jgb.166589$0v4.12607681@bgtnsc04-
    news.ops.worldnet.att.net>,
    says...
    > Is it possible to access the value of a radio button or change a radio
    > button to enabled/disabled without using the forms tags<FORM></FORM>? In
    > other words is the forms tag required for these actions?


    If you have <input>s you need <form>. There's no reason to leave it
    out, is there?

    --
    Hywel I do not eat quiche
    http://hyweljenkins.co.uk/
    http://hyweljenkins.co.uk/mfaq.php
    Hywel Jenkins, Oct 6, 2003
    #2
    1. Advertising

  3. Hywel Jenkins <> writes:

    > In article <n6jgb.166589$0v4.12607681@bgtnsc04-
    > news.ops.worldnet.att.net>,
    > says...
    > > Is it possible to access the value of a radio button or change a radio
    > > button to enabled/disabled without using the forms tags<FORM></FORM>? In
    > > other words is the forms tag required for these actions?

    >
    > If you have <input>s you need <form>.


    No. While Netscape 4 can't accept form controls outside of a form tag,
    the HTML specification allows them, and it works in all modern browsers.

    > There's no reason to leave it out, is there?


    Lots of reasons. A form element requires an action attribute. If you
    don't have a reasonable action to add, then it is a good sign that what
    you are doing isn't a form.


    For the original question: Yes, it is possible. You can access any
    element on the page. For form controls inside a form element, there is
    an extra way to access them: the form through the "forms" collection
    and the controls through the "elements" collection of the form.

    If you have an input element with no form, you must access it directly,
    so you should give it a unique identifier:
    <input type="text" value="my text" id="myInputId">
    You can the access the value as
    document.getElementById("myInputId").value

    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Oct 6, 2003
    #3
    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. Eric
    Replies:
    2
    Views:
    1,449
    Tommy
    Feb 13, 2004
  2. jstack
    Replies:
    1
    Views:
    600
    Tor Iver Wilhelmsen
    Jul 4, 2003
  3. kishan bisht

    struts tag inside a tag

    kishan bisht, Jul 8, 2003, in forum: Java
    Replies:
    1
    Views:
    1,483
    Wendy S
    Jul 9, 2003
  4. shruds
    Replies:
    1
    Views:
    779
    John C. Bollinger
    Jan 27, 2006
  5. Eric
    Replies:
    2
    Views:
    484
Loading...

Share This Page