[Javascript] checkbox to change input field value

Mike Dougherty mdougherty at pbp.com
Mon May 22 08:03:27 CDT 2006


I don't know how well this suggestion works with multiple checkboxes having the same name (perhaps 
the already suggested solutions are 'better')

I made a point of doing this:
<input type='checkbox' name='Data1' value='D1' />
<input type='hidden' name='Data1' value='X' />

If the checkbox IS checked, the value of "Data1" is 'D1,X'
If the checkbox is NOT checked, the value of "Data1" is only 'X'

If you do this, you will always be checking (asp example)
if (Request.Form("Data1").split(',')[0] == "X") { did_not_check_Data1_checkbox }

It is definately a hack.  You get the idea. ymmv

On Mon, 22 May 2006 13:05:58 +0100
  "Alan Easton" <alaneaston666 at hotmail.com> wrote:
> Hi All,   I have a list of 5 checkboxes on a form and each one has the same name "ids", but 
>different values.   What I would like to do when I submit the form, is find out which checkbox 
>was NOT checked.   I realise this is not straight forward, as if a checkbox is not checked, it is 
>not submitted to the server, but can anyone think of a way round this.   I am using ASP, and 
>wanted to simply have the list of ones that were NOT checked returned in a comma seperated list 
>or something like that.   Does anyone have any ideas. Any help would be appreciated.   Thanks, 
  




More information about the Javascript mailing list