If the checkbox is checked return value is:
/doCheckBox.asp?checkbox-1=true
if the checkbox is unchecked I'm not getting anything in response:
/doCheckBox.asp?
Is there any way to return unchecked checbox value widouth using hidden attribute ?
doCheckBox.asp
<%
Option Explicit
Response.Expires = 0
Dim cb1
cb1 = Request("checkbox-1")
Response.Write(cb1)
%>
checkBox.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="http://ift.tt/20g0BuL"></script>
<script src="http://ift.tt/2dsPzTA"></script>
<script>
$(document).on("ready", function() {
$('input').checkboxradio();
$('button').button();
$('#button').on('click', function(){
var cb2 = $('#checkbox-2').prop('checked') ? true : false;
var cb1 = $('#checkbox-1').prop('checked') ? true : false;
var cb3 = $('#checkbox-3').prop('checked') ? true : false;
var cb4 = $('#checkbox-4').prop('checked') ? true : false;
var cb5 = $('#checkbox-5').prop('checked') ? true : false;
alert(" " + cb1 + " " + cb2 + " " + cb3 + " " + cb4 + " " + cb5)
submitForm();
});
});
function submitForm() {
$('#form1').attr('action', "doCheckBox.asp").submit( function(){
var cb1 = $('#checkbox-1').prop('checked') ? true : false;
$('#checkbox-1').val(cb1);
});
}
</script>
</head>
<body>
<div class="widget">
<h2>Checkbox</h2>
<form id="form1" method="get">
<fieldset>
<legend>Hotel Ratings: </legend>
<label for="checkbox-1">1 Star</label>
<input type="checkbox" name="checkbox-1" id="checkbox-1">
<label for="checkbox-2">2 Star</label>
<input type="checkbox" name="checkbox-2" id="checkbox-2">
<label for="checkbox-3">3 Star</label>
<input type="checkbox" name="checkbox-3" id="checkbox-3">
<label for="checkbox-4">4 Star</label>
<input type="checkbox" name="checkbox-4" id="checkbox-4">
<label for="checkbox-5">5 Star</label>
<input type="checkbox" name="checkbox-5" id="checkbox-5">
<button id="button" type="submit" onClick="submitForm()">Open Dialog</button>
</fieldset>
</form>
</div>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire