Radio button and text link

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kwart246

    Radio button and text link

    Hello,

    Is it possible to use a text link to enable a radio button, just like some
    windows interfaces, when the text is clicked, the radio button gets
    selected.....

    This works for a checkbox:
    in head:
    function changeBox(cbox) {
    box = eval(cbox);
    box.checked = !box.checked;
    }

    Then as link:
    <a href="" onClick="change Box('document.f orm1.textfield' );return
    false">click this<a>

    But I want it to select a radio button instead of a checkbox....
    anyone?


  • Michael Winter

    #2
    Re: Radio button and text link

    On Mon, 25 Oct 2004 14:58:05 +0200, Kwart246 <kwartmeloen@ho tmail.com>
    wrote:
    [color=blue]
    > Is it possible to use a text link to enable a radio button, just like
    > some windows interfaces, when the text is clicked, the radio button gets
    > selected.....[/color]

    That's what LABELs are for.

    <label for="controlId" >Label text
    <input id="controlId" type="radio" ...>
    </label>

    The for/id combination, or the control-as-content can be used separately,
    but I've read that some older browsers only understand one, so its best to
    combine both.
    [color=blue]
    > This works for a checkbox:
    > in head:
    > function changeBox(cbox) {
    > box = eval(cbox);
    > box.checked = !box.checked;
    > }[/color]

    function changeRadio(rad ) {
    rad.checked = true;
    }
    [color=blue]
    > Then as link:
    > <a href=""[/color]

    Make that "#". IE doesn't recognise an empty URI as the current document
    (though it does with the FORM action attribute). Stupid piece of junk.
    [color=blue]
    > onClick="change Box('document.f orm1.textfield' );return false">click
    > this<a>[/color]

    It would be far more sensible to pass a reference to the function, not a
    string which you then coerce into a reference.

    onclick="change Radio(document. formName.elemen tName);return false;"

    Though I prefer use of the forms and elements collections.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    Working...