Forms tag question

D

Dave F.

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

Hywel Jenkins

news.ops.worldnet.att.net>, (e-mail address removed)
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?
 
L

Lasse Reichstein Nielsen

Hywel Jenkins said:
news.ops.worldnet.att.net>, (e-mail address removed)
says...

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
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top