Disable all form field except submit button

M

millw0rm

i got a form full of radio buttons appx. 60-70, depends on the page.
Some times 60, sometimes 55.... After certain period of time, i want to
disable or make readonly all the radio button inside the form except
submit button.

i have done the timing part, i hav setup a running clock which will
trigger the event @ XX amount of time but i m unable to make the radio
button disable or read only! remember submit button shld be available
to submit the form....

can ou please help???/


thnx
 
J

Jeremy

i got a form full of radio buttons appx. 60-70, depends on the page.
Some times 60, sometimes 55.... After certain period of time, i want to
disable or make readonly all the radio button inside the form except
submit button.


thnx

You'll probably want to make them read-only, as making them disabled
will prevent their values from being submitted to the server.

function makeAllReadOnlyExceptSubmit()
{
var f = document.getElementById("idOfYourForm");
var inputs = f.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++)
if(inputs.type != "submit")
inputs.readOnly = true;
}
 
J

Jeremy

Jeremy said:
function makeAllReadOnlyExceptSubmit()
{
var f = document.getElementById("idOfYourForm");
var inputs = f.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++)
if(inputs.type != "submit")
inputs.readOnly = true;
}


Actually, you probably don't even need to check whether it's a submit
button or not - I don't think making a submit button read-only will
prevent it from being operational (techically it's ALWAYS read-only
since the user can't affect its value).

Jeremy
 
M

millw0rm

not working!!! radio buttons are still available to select and change
value

Jeremy said:
function makeAllReadOnlyExceptSubmit()
{
var f = document.getElementById("idOfYourForm");
var inputs = f.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++)
if(inputs.type != "submit")
inputs.readOnly = true;
}


Actually, you probably don't even need to check whether it's a submit
button or not - I don't think making a submit button read-only will
prevent it from being operational (techically it's ALWAYS read-only
since the user can't affect its value).

Jeremy
 
J

Jeremy

not working!!! radio buttons are still available to select and change
value

At the end of the day, it's up to your user-agent to decide whether the
read-only attribute will even be honored, and what effect it will have
if it is.

Do you have a URL or code snippet? It would be very helpful in
determining why your code isn't working.

Jeremy
 
J

James Black

i have done the timing part, i hav setup a running clock which will
trigger the event @ XX amount of time but i m unable to make the radio
button disable or read only! remember submit button shld be available
to submit the form....

How are you setting the clock?

You may want to put an alert where it sets them to readonly, to verify
that it is indeed getting there.

For the timer, you may want to look at setTimeout, which is a
javascript function.
 
M

millw0rm

Sorry application is in offline mode, form is generated by php...

i tried it on IE6 & 7, firefox, opera as well as on Safari its not
working...

i hav inserted an alert jst before and after your code... both the
alert event is triggered but readonly is not working...
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top