Hii guys,
I have a form where in on click of a checkbox i hide and show a textfield which is working fine . but when i refresh the page the text box gets hidden and the value is also lost ... is there any way so that when ever the checkbox is checked the textbox is visible along with its value. i have posted the code too.
and here is page.css
I have a form where in on click of a checkbox i hide and show a textfield which is working fine . but when i refresh the page the text box gets hidden and the value is also lost ... is there any way so that when ever the checkbox is checked the textbox is visible along with its value. i have posted the code too.
Code:
<script type="text/javascript" src="/JS/page.js"></script>
<form name="test123" id="test2" method="POST">
<div class="fieldForm" id="fieldForm" >
<fieldset id="personnel">
<legend>DO YOU KNOW</legend>
<!-- one field start -->
<div class="field50Pct">
<div class="fieldItemLabel">
<label for="What is Diabetes">What is Diabetes:</label>
</div>
<div class="fieldItemValue">
<?php
if($_POST['what_is_diabetes']=='YES'){
$chk1="checked";
}
?>
<input onclick="EnableDisableDIV(this.id,'hide1')" type="checkbox" name="what_is_diabetes" id="what_is_diabetes" value="YES" <?php echo $chk1 ?>> <span class="star">*</span>
</div>
</div>
<?php
if(isset($_POST['what_is_diabetes'])){
echo "<div id='hide1'>";
}
else {
echo "<div id='hide1' style='display:none'>";
}
?>
<div class="field50Pct">
<div class="fieldItemLabel">
<label for=''> </label>
</div>
<div class="fieldItemValue">
<input type="text" id="diabetes_date" name="diabetes_date" value="<?php $_POST['diabetes_date'] ?>" />
<div id="cal">
<a href="javascript:NewCssCal('diabetes_date','yyyymmdd')">
<img src="/sample/images/cal.gif" width="16" height="16" alt="Pick a date"></a>
</div>
</div>
</div>
</div>
<div class="clear"></div>
<!-- one field end -->
and here is page.css
Code:
function EnableDisableDIV(fieldid,divid) {
if ($("#"+fieldid).attr("checked")) {
$("#"+divid).show('slow');
} else {
$("#"+divid).hide('slow');
}
}
Comment