Hi
I am trying to enable the fileds with help of radio button is selected below are my code, its working fine for inserting a value in database. I can able to fetch the datas from database for display except the radio button is not getting selected from the database value.
can you please help me how can i solve this issue.
<script>
window.onload = function() {
document.getElementById('daily').onchange = disablefield;
document.getElementById('weekly').onchange = disablefield;
}
function disablefield()
{
if (document.getElementById('daily').checked == true )
{
document.getElementById('wdays1').value = '';
document.getElementById('wdays1').disabled = true
document.getElementById('wdays2').value = '';
document.getElementById('wdays2').disabled = true
document.getElementById('wdays3').value = '';
document.getElementById('wdays3').disabled = true
document.getElementById('wdays4').value = '';
document.getElementById('wdays4').disabled = true
document.getElementById('wdays5').value = '';
document.getElementById('wdays5').disabled = true
document.getElementById('wdays6').value = '';
document.getElementById('wdays6').disabled = true
document.getElementById('wdays7').value = '';
document.getElementById('wdays7').disabled = true
document.getElementById('dstime').value = '';
document.getElementById('dstime').disabled = false
document.getElementById('detime').value = '';
document.getElementById('detime').disabled = false
}
else if (document.getElementById('weekly').checked == true )
{
document.getElementById('wdays1').value = '';
document.getElementById('wdays1').disabled = false
document.getElementById('wdays2').value = '';
document.getElementById('wdays2').disabled = false
document.getElementById('wdays3').value = '';
document.getElementById('wdays3').disabled = false
document.getElementById('wdays4').value = '';
document.getElementById('wdays4').disabled = false
document.getElementById('wdays5').value = '';
document.getElementById('wdays5').disabled = false
document.getElementById('wdays6').value = '';
document.getElementById('wdays6').disabled = false
document.getElementById('wdays7').value = '';
document.getElementById('wdays7').disabled = false
document.getElementById('dstime').value = '';
document.getElementById('dstime').disabled = true
document.getElementById('detime').value = '';
document.getElementById('detime').disabled = true
}
}
</script>
My code
<div class="form-group">
<div class="col-sm-2">
<label class="radio-inline">
<input class="icheck" type="radio" value="D" id="daily"<?php $smethod = odbc_result($ssrow,"SHYQ64EV05"); if($smethod=='D') { ?> checked <?php } ?>name="smethod">
Daily </label>
</div>
<div class="col-sm-10">
<div class="col-sm-2">Start Time
<input type="text" class="form-control" size="16" id="dstime" value="<?php echo $SHYQ64JSTM= odbc_result($ssrow,"SHYQ64JSTM");?>" name="dstime">
</div>
<div class="col-sm-2">End Time
<input type="text" class="form-control" size="16" id="detime" name="detime" value="<?php echo $SHYQ64JENT = odbc_result($ssrow,"SHYQ64JENT"); ?>" placeholder="00:00:00">
</div>
</div>
</div>
<!--- Weekly --->
<div class="form-group">
<div class="col-sm-2">
<label class="radio-inline">
<input class="icheck" type="radio" id="weekly" value="W" <?php $smethod = odbc_result($ssrow,"SHYQ64EV05"); if($smethod=='W') { ?>checked <?php } ?> name="smethod">
Weekly </label>
</div>
<div class="col-sm-10">
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays1" name="Monday" value="1"<?php $SHYQ64MOND = odbc_result($ssrow,"SHYQ64MOND"); if($SHYQ64MOND=='1') { ?>checked <?php } ?> >
Monday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays2" name="Tuesday" value="1"<?php $SHYQ64TUES = odbc_result($ssrow,"SHYQ64TUES"); if($SHYQ64TUES=='1') { ?>checked <?php } ?>>
Tuesday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays3" name="Wednesday" value="1"<?php $SHYQ64WEDN = odbc_result($ssrow,"SHYQ64WEDN"); if($SHYQ64WEDN=='1') { ?>checked <?php } ?>>
Wednessday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays4" name="Thursday" value="1"<?php $SHYQ64THUR = odbc_result($ssrow,"SHYQ64THUR"); if($SHYQ64THUR=='1') { ?>checked <?php } ?>>
Thursday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays5" name="Friday" value="1"<?php $SHYQ64FRDY = odbc_result($ssrow,"SHYQ64FRDY"); if($SHYQ64FRDY=='1') { ?>checked <?php } ?>>
Friday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays6" name="Saturday" value="1"<?php $SHYQ64STDY = odbc_result($ssrow,"SHYQ64STDY"); if($SHYQ64STDY=='1') { ?>checked <?php } ?>>
Saturday </div>
<div class="col-sm-2">
<input class="icheck" type="checkbox" id="wdays7" name="Sunday" value="1"<?php $SHYQ64SUND = odbc_result($ssrow,"SHYQ64SUND"); if($SHYQ64SUND=='1') { ?>checked <?php } ?>>
Sunday </div>
</div>
</div>