Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Checkbox Question

Status
Not open for further replies.

TonyRosen

Programmer
Jul 28, 2003
108
US
I am creating a form with 7 checkbox fields. One of the checkbox fields needs to be checked, disabled, and still send the result. For example:

<form>
<input type=&quot;checkbox&quot; value=&quot;checked&quot;> Field Checked
</form>

How do I disable that but still get the &quot;checked&quot; value?
 
<input type=&quot;checkbox&quot; name=&quot;XXXXX&quot; checked disabled>
 
I don't think disabled items are submitted. if you know the item is going to be checked, just do whatever you would do, normaly on the action page, only manualy add the field's value to the list.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
- Quote by Douglas Adams
 
I guess the basic point is that if you are disabling it you have to already know whether it is checked or not since there is by definition no user input.

However you determine that, just store the value in a hidden field that you can submit along.
 
Oddly enough ... that makes sense ... I was over-thinking the problem.
 
or, &quot;re-enable&quot; the input(s) just prior to submitting the form so that they get sent. you could do this for just the few inputs you have on the page, e.g.,
Code:
  myFormName.myInputName.disabled = false;
or, loop through all elements on the page and just enable everything, if you have a lot of these...
Code:
  var f = document.forms['myFormName'];
  var e;
  for (var i=0; i<f.length; i++) {
    e=f.elements[i];  
    e.disabled = false;
  }

put this all into a function that gets called by the form's &quot;onSubmit&quot; event...

good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top