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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox values

Status
Not open for further replies.

London12345

Programmer
Jun 30, 2011
5
GB
I'm trying to pass Y or N to the database based on the checkbox selection but instead of Y or N "on" is being passed to the database and if nothing is checked then null is being passed instead of N .Please can you advise on this.

<html>
<head>
<!--<defanghtml_script type="text/javascript">
function handleChange(ids) {
var y=ids.id;
var z=y.length;
var aa="c"+y.charAt(z-1);
var name=ids.name;
alert(document.getElementById(aa).checked)
if(document.getElementById(aa).checked==true){
document.getElementsByName(name).value='Y';
alert( document.getElementsByName(name).value);
}
else{
document.getElementsByName(name).value='N';
alert( document.getElementsByName(name).value);
}
}

</defanghtml_script>-->
</head>
<body>

<defanghtml_input type="checkbox" name="cw" id="c1" onclick="handleChange(this)"/>
<defanghtml_input type="checkbox" name="li" id="c2" onclick="handleChange(this)"/>
<defanghtml_input type="checkbox" name="hw" align="middle" id="c3" onclick="handleChange(this)"/>
<defanghtml_input type="checkbox" name="dp" align="middle" id="c4" onclick="handleChange(this)"/>

</body>
</html>
 
Hi

[ul]
[li]Please post HTML, not server-side code. ( Or at least no without specifying what kind of language is that. ([/li]
[li]Explain what is your goal with that event handler, in case it is related to the problem.[/li]
[li]Note that unchecked [tt]checkbox[/tt] and [tt]radio[/tt] [tt]input[/tt]s are not included in the submitted [tt]form[/tt] data.[/li]
[li]For now all this sounds off-topic here, as client-side code can not interact with server-side database.[/li]
[/ul]


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top