Radio button and text link

K

Kwart246

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="changeBox('document.form1.textfield');return
false">click this<a>

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

Michael Winter

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.....

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.
This works for a checkbox:
in head:
function changeBox(cbox) {
box = eval(cbox);
box.checked = !box.checked;
}

function changeRadio(rad) {
rad.checked = true;
}
Then as link:
<a href=""

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.
onClick="changeBox('document.form1.textfield');return false">click
this<a>

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

onclick="changeRadio(document.formName.elementName);return false;"

Though I prefer use of the forms and elements collections.

[snip]

Mike
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top