Jquery disable child element of the same parent - javascript

I don't want to copy any of the questions asked before, but I have hard time to solve my problem.
I have a form with few checkbox-es, some of them are hidden to trigger output when checkbox is unchecked. At the end of the page I have JQuery code, that should disable those hidden checkboxes if I enable general boxes, but this code doesn't work. Whenever I click to any checkbox, EVERY other checkboxes become unchecked! I think it happens because I cant aim to the only one needed element.
Maybe you didn't understand, but if you look at the code, you will find out exactly what is wrong!
<form action="" method="GET" name="<?php echo $listFilter['forn_name']; ?>" id="<?php echo $listFilter['forn_name']; ?>">
<span>
<input type="checkbox" value="1" name="word" id="word_checkbox" class="checkbox" <?php if($listFilter['word_status'] == 1){ ?> checked <?php } ?>/>
<input type='hidden' value='0' name='word' class="checkbox_hidden" <?php if($listFilter['word_status'] == 0){ ?> checked <?php } ?>/>
<label class="label" for="word_checkbox">Words</label>
</span>
<span>
<input type="checkbox" value="1" name="pron" id="pron_checkbox" class="checkbox" <?php if($listFilter['pronunciation_status'] == 1){ ?> checked <?php } ?> />
<input type='hidden' value='0' name='pron' class="checkbox_hidden" <?php if($listFilter['pronunciation_status'] == 0){ ?> checked <?php } ?>/>
<label class="label" for="pron_checkbox">Pronunciation</label>
</span>
<span>
<input type="checkbox" value="1" name="pos" id="pos_checkbox" class="checkbox" <?php if($listFilter['pos_status'] == 1){ ?> checked <?php } ?> />
<input type='hidden' value='0' name='pos' class="checkbox_hidden" <?php if($listFilter['pos_status'] == 0){ ?> checked <?php } ?>/>
<label class="label" for="pos_checkbox">Part of speech</label>
</span>
<span>
<input type="checkbox" value="1" name="meaning" id="meaning_checkbox" class="checkbox" <?php if($listFilter['meaning_status'] == 1){ ?> checked <?php } ?> />
<input type='hidden' value='0' name='meaning' class="checkbox_hidden" <?php if($listFilter['meaning_status'] == 0){ ?> checked <?php } ?>/>
<label class="label" for="meaning_checkbox">Meaning</label>
</span>
<span>
<input type="checkbox" value="1" name="examples" id="examples_checkbox" class="checkbox" <?php if($listFilter['examples_status'] == 1){ ?> checked <?php } ?> />
<input type='hidden' value='0' name='examples' class="checkbox_hidden" <?php if($listFilter['examples_status'] == 0){ ?> checked <?php } ?>/>
<label class="label" for="examples_checkbox">Examples</label>
</span>
<script>
$(document).ready(function(){
$("#<?php echo $listFilter['forn_name']; ?> .checkbox").change(function() {
/* I reckon those codes bellow are causing problem */
var parent = $(this).closest('span');
if(this.checked){$(this).parent("span").children(".checkbox_hidden").prop('disabled', true);}
document.forms.<?php echo $listFilter['forn_name']; ?>.submit();
});
});
</script>
</form>
Thanks to Alexander, there is a sample code on JSFiddle. http://jsfiddle.net/TH2hh/

Related

show number of radio button checked instantaneous

I have radio buttons with name as 2d array in a while loop.I want to show the number of radio buttons checked when its clicked.
my radio buttons
$n=0;
while($row= mysqli_fetch_row($rs)){?>
<form name="myfm" id="myfm" method="post" action="Quizn.php">
<table width=100%> <tr> <td width=30><td></td></td></tr> <table border=0>
<?php $n=$n+1; ?>
<tr><td>Question <?php echo $n.") "; echo $row[2]; ?></td></tr>
<tr><td class=style8>A. <input type="radio" name="ques['<?php echo $n; ?>'][]" value=1><?php echo $row[3]; ?></td></tr>
<tr><td class=style8>B. <input type="radio" name="ques['<?php echo $n; ?>'][]" value=2><?php echo $row[4];?></td></tr>
<tr><td class=style8>C. <input type="radio" name="ques['<?php echo $n; ?>'][]" value=3><?php echo $row[5];?></td></tr>
<tr><td class=style8>D. <input type="radio" name="ques['<?php echo $n; ?>'][]" value=4><?php echo $row[6];?></td></tr>
<input type="hidden" name="ques['<?php echo $n; ?>'][]" value="0" />
<input type="hidden" value="<?php echo $row[0]; ?>" name="qid[]" />
<?php }
echo "<tr><td><input type=submit name=submit id='result' value='Get Result'></form>";
?>
</table></table>
</form>
<p>Clicked:</p> <p id="clicked">0</p>
javascript
$("input:radio").click(function () {
var totalRd = $('table').find(':not(.pend) > input:radio:checked').length;
$("#totalRd .rd-count").html(totalRd);
});
Please help me if you know the solution.
Thankyou
With some assumption, try like this
<?php
if(isset($_POST['submit'])){
echo "<pre>";
print_r($_POST);
echo "</pre>";
}
?>
<form method="post" action="">
<?php for ($i=0; $i < 3 ; $i++) { ?>
<br>
A<input type="radio" name="ques[<?php echo $i;?>][]" value=1>
B<input type="radio" name="ques[<?php echo $i;?>][]" value=2>
C<input type="radio" name="ques[<?php echo $i;?>][]" value=3>
D<input type="radio" name="ques[<?php echo $i;?>][]" value=4>
<?php } ?>
<br>
<input type="submit" name="submit" value="submit">
</form>
http://screencast.com/t/HEVSPR7yVR
http://screencast.com/t/rQSpXiJAMg
I suggest don't use array here name="ques[<?php echo $i;?>][]" just use name="ques[<?php echo $i;?>]" for clean and clear
Try this
$(":radio").on( 'click', function() {
count = $(':radio:checked').length;
alert(count);
});

How to check if all the radio button gropus in a division are checked or not?

I am weighting a code where user will select their answer for questions they are asked.
There would be multiple questions per page. And I want all those questions to be answered.
Below is the code of the questions form where questions are being called dynamically from database in a loop.
<form id="radio-demo" class="radio-demo" action="<?php echo get_site_url(); ?>/register-response" method="POST">
<?php
/* print_r($categories); */
/*loop to get questions for each categories*/
foreach($cat as $categories){
$software = $wpdb->get_results("SELECT * FROM ". $wpdb->prefix ."statement where statement_category_id =".$categories->statement_category_id);
$j++;
$table = $software;
$c_id = $categories->statement_category_id;
$i = 0;
?>
<div class="custom_hide" id="page_<?php echo $j;?>">
<?php
$cat_name = $categories->statement_category;
/*loop for the number of questions per category */
foreach($table as $software) {
$i++;
?>
<div class="question_one">
<p><?php echo $i.". ".$software->statement;?></p>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="first-choice-<?php echo $i;?>" value="<?php echo 1*$software->weight;?>" required = "required"/>
<label for="first-choice">1</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="second-choice-<?php echo $i;?>" value="<?php echo 2*$software->weight;?>" required = "required"/>
<label for="second-choice">2</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="third-choice-<?php echo $i;?>" value="<?php echo 3*$software->weight;?>" required = "required"/>
<label for="third-choice">3</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="four-choice-<?php echo $i;?>" value="<?php echo 4*$software->weight;?>" required = "required"/>
<label for="four-choice">4</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="five-choice-<?php echo $i;?>" value="<?php echo 5*$software->weight;?>" required = "required"/>
<label for="five-choice">5</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="six-choice-<?php echo $i;?>" value="<?php echo 6*$software->weight;?>" required = "required"/>
<label for="six-choice">6</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="seven-choice-<?php echo $i;?>" value="<?php echo 7*$software->weight;?>" required = "required"/>
<label for="seven-choice">7</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="eight-choice-<?php echo $i;?>" value="<?php echo 8*$software->weight;?>" required = "required"/>
<label for="eight-choice">8</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="nine-choice-<?php echo $i;?>" value="<?php echo 9*$software->weight;?>" required = "required"/>
<label for="nine-choice">9</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="ten-choice-<?php echo $i;?>" value="<?php echo 10*$software->weight;?>" required = "required"/>
<label for="ten-choice">10</label>
</label>
<label class="radio-inline">
<input type="radio" name="<?php echo $c_id.'_'.$i;?>" id="eleven-choice-<?php echo $i;?>" value="<?php echo 0*$software->weight;?>" required = "required"/>
<label for="eleven-choice">No Opinion</label>
</label>
<!-- <input type="hidden" name="currentID" value="<?php echo $c_id; ?>" />-->
</div> <?php }?>
<div class="bottum_btn">
<div class="">
<?php if($j > 1){?>
<div class="back_btn">
<a onclick="custom_back(<?php echo $j-1;?>)"><i class="fa fa-chevron-circle-left">Back</i> </a>
</div>
<?php
}
if($j == $catcount){?>
<div class="next_btn">
<input name="submit" type="submit" id="submit_btn" value="submit""><i class="fa fa-chevron-circle-right"></i></input>
</div>
<!--<a name="submit" id="submit_btn" onClick="PopUp()">submit<i class="fa fa-chevron-circle-right"></i>
</a>-->
<?php } else
{
?>
<div class="next_btn">
<a onclick="custom_next(<?php echo $j+1;?>)">Next<i class="fa fa-chevron-circle-right"></i> </a>
</div><?php
}?>
</div>
</div>
</div>
<?php }?>
The script I am trying is as below.
function custom_next(val) {
var val1 = "#page_" + val;
var val2 = "#page_" + (val - 1);
var questions = jQuery(".question_one");
var maindiv = jQuery(val2);
if (jQuery(val2+':not(:has(:radio:checked))').length > 1) {
console.log(jQuery(val2+':not(:has(:radio:checked))').length);
alert("At least one group is blank");
}else{
console.log(jQuery(val2+':not(:has(:radio:checked))').length);
jQuery(val1).removeClass("custom_hide");
jQuery(val1).addClass("custom_show");
jQuery(val2).removeClass("custom_show");
jQuery(val2).addClass("custom_hide");
}}
But this script is checking for "if any of the radio button group is checked or not" where I want all of the radio button groups to be checked.
I have analyzed your code and I have developed this code for your script. This scripts checks if any of your question options is checked or not.
function custom_next(val) {
var val1 = "#page_" + val;
var val2 = "#page_" + (val - 1);
var i = 0;
var j = 0;
jQuery('div.custom_show input[type=radio]').each(function(){
var status = jQuery(this).is(':checked');
//alert(status);
i=i+1;
if(status == true){
j=j+1;
}
});
i= i/11;
if(i == j){
jQuery(val1).removeClass("custom_hide");
jQuery(val1).addClass("custom_show");
jQuery(val2).removeClass("custom_show");
jQuery(val2).addClass("custom_hide");
}else{
alert("All Questions are mandetory!!");
}
}
First find all the radio button groups inside your form
var radio_groups = [];
$("#radio-demo :radio").each(function(){
radio_groups.push(this.name);
});
Now iterate through all of them to see if any one is not selected
var isAnyUnselected = radio_groups.filter( function(vallue){
return $(":radio[name='"+group+"']:checked").length == 0
} ).length > 0;
check if isAnyUnselected is true (some are unselected) or false (all of them are selected)
But this script is checking for "if any of the radio button group is checked or not" where I want all of the radio button groups to be checked.
What you need to do is check if there is at least one radio box that is not checked. Small example:
<input class="ans" type="radio"/>
<input class="ans" type="radio"/>
if ($('.ans').not(':checked').length)
{
console.log('At least one not checked, please check all');
}
else
{
console.log('All checked');
}
If you don´t want to change the html you can use the selector jQuery("input[type='radio']:not(:checked)") if the .length of this selector is greater than 1 there are some input to check. Simple example here se the console logs.
Otherwise you could use the required attribute link1 link2.

Ignore checkbox that is disable

I have here a code that when you clicked the All link it will check all the check boxes and when None it will uncheck all the check boxes.
But I have a PHP conditions that when the $pta_fee == $pta_fee_trans the check box will be disable, but when I clicked the All link, the disable check box appears to be checked.
How can I ignore the disable check box if I checked the All link?
<div class="sub_profile right">
<p class="sub_content_text" style='margin-left: 25px;'>
All | None
MISCELLANEOUS FEES:
</p>
<?php
if($pta_fee == $pta_fee_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $pta_fee; ?>" disabled>
PTA Fee : ₱ <?php echo $pta_fee; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $pta_fee; ?>" id="required-checkbox1" onClick="CheckIfChecked(this.id)">
PTA Fee : ₱ <?php echo $pta_fee; ?></p>
<?php
}
if($maintenance_fee == $maintenance_fee_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $maintenance_fee; ?>" disabled>
Maintenance Fee : ₱ <?php echo $maintenance_fee; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $maintenance_fee; ?>" id="required-checkbox2" onClick="CheckIfChecked(this.id)">
Maintenance Fee : ₱ <?php echo $maintenance_fee; ?></p>
<?php
}
if($id_school == $id_school_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $id_school; ?>" disabled>
School ID : ₱ <?php echo $id_school; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $id_school; ?>" id="required-checkbox3" onClick="CheckIfChecked(this.id)">
School ID : ₱ <?php echo $id_school; ?></p>
<?php
}
if($electricity == $electricity_trans)
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' value="<?php echo $electricity; ?>" disabled>
Electricity : ₱ <?php echo $electricity; ?></p>
<?php
}
else
{
?>
<p class="sub_content_text" style='margin-left: 30px;'>
<input type='checkbox' name='draw[]' value="<?php echo $electricity; ?>" id="required-checkbox4" onClick="CheckIfChecked(this.id)">
Electricity : ₱ <?php echo $electricity; ?></p>
<?php
}
?>
<div id="sub_profile_cont">
<div class="sub_profile left">
<p class="block_cont left">
<div id = "submit-button-container" style="display:none;">
<input class="action_btn" type="submit" name="submit" id="pay_btn" value="COMPUTE" onClick="setUpdateAction();"/>
</div>
<b style="display: none";><input class="action_btn" type="submit" name="submit" id="pay_btn" value="COMPUTE" onClick="setUpdateAction();"/></b>
</p>
</div>
</div>
</div>
--Here's the javascript code for checking all the check boxes:
<script>
function selectToggle(toggle, form) {
var myForm = document.forms[form];
for( var i=0; i < myForm.length; i++ ) {
if(toggle) {
myForm.elements[i].checked = "checked";
}
else {
myForm.elements[i].checked = "";
}
}
}
Try this:
<script>
function selectToggle(toggle, form) {
var myForm = document.forms[form];
for( var i=0; i < myForm.length; i++ ){
if(myForm.elements[i].disabled != true){
if(toggle){
myForm.elements[i].checked = "checked";
}
else{
myForm.elements[i].checked = "";
}
}
}
}

PHP show error if inputbox1 > inputbox2

I designed a php page if current time is greater than end time it show as closed else it show data entry form.
In that form I have several input boxes some get value from database.remain input boxes accept value less than their pair input box.else it show error and focus user to change that field how ... I tried with following code but cannot get expected result... Any solution...
<?php
include("head.php");
?>
<?php
$end = ('04:15:00 PM');
$now=date('H:i:s A');?>
<?php
$newdateformat = date("d_m_y");
$ttaerr="";
mysql_select_db($mysql_database,$bd);
$se_sql=mysql_query("select * from $newdateformat where S_No='$login_sess' ");
$row=mysql_fetch_array($se_sql);
$name=$row['S_Name'];
$address=$row['Address'];
$tamil= $row['Tamil1'];
$english=$row['English1'];
$maths= $row['Maths1']; ?>
<label> Your Name : <?php echo $login_sess;?> - <?php echo $name;?> - <?php echo $address;?> </label><br />
<?php
if($end > $now){
echo "Entry 1 Closed :";
}
else
{
?>
<form id='form1' name='form1' method='post' action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>'>'
<p>
<label for='tamil1'>Tamil 1 : </label>
<input name='tamil1' type='text' id='tamil1' value='<?php echo $tamil;?>' readonly="readonly" disabled="disabled"/>
</p>
<p>
<label for='tamil2'>Tamil 2 : </label>
<input name='tamil2' type='text' id='tamil2' maxlength="3" required='required' /> <?php echo $ttaerr;?>
</p>
<p>
<label for='tamil1'>English 1 : </label>
<input type='text' name='english1' id='english1' value='<?php echo $english;?>' readonly="readonly" disabled="disabled"/>
</p>
<p>
<label for='tamil2'>English 2 : </label>
<input type='text' name='english2' id='english2' required='required' maxlength="3" />
</p>
<p>
<label for='tamil1'>Maths 1 : </label>
<input type='text' name='maths1' id='maths1' value='<?php echo $maths;?>' readonly="readonly" disabled="disabled" />
</p>
<p>
<label for='tamil2'>Maths 2 : </label>
<input type='text' name='maths2' id='maths2' required='required' maxlength="3" />
</p>
<p> </p>
<p>
<input type='submit' name='submit' id='submit' value='Submit' />
</p>
</form>
<?php
if($_SERVER['REQUEST_METHOD']=="POST")
{ if(isset($_POST['tamil1'])&&isset($_POST['tamil2'])&&isset($_POST['english1'])&&isset($_POST['english2'])&&isset($_POST['maths1'])&&($_POST['maths2']))
{
$newta1=$_POST['tamil1'];
$newta2=$_POST['tamil2'];
$newen1=$_POST['english1'];
$newen2=$_POST['english2'];
$newma1=$_POST['maths1'];
$newma2=$_POST['maths2'];
if(($newta1 > $newta2)&&($newen1 > $newen2)&&($newma1 > $newma2))
{
$sql="UPDATE $newdateformat SET Time='$now',Tamil2='newta2',English2='$newen2',Maths2='$newma2' WHERE S_NO='$login_sess' and S_Name='$name'";
$result=mysql_query($sql);
if(!$result)
{
die ('Error:'.mysql_error().'<br> Back');
}
echo 'Your Record added on :'.$now.'<br> Back';
mysql_close($con);
}
else {
echo("Try Eng...");
}}
}
}
?>
</body>
</html>

How to make a textfield Editable when checkbox is checked?

Actually, I have many checkboxes and textfields coming from database through single code. I need that when I check a particular checkbox, then a textfield in front of that checkbox to become editable. How can I do that ?
Here is my PHP code
<div class="my"><?php
while ($ass = mysql_fetch_array($rs)) {?>
<input type="checkbox" name="fees_name[]" id="fee_name" value="<?php echo $ass['fees_name']; ?>" onclick='toggleReadonly(this)'>
<?php echo $ass['fees_name']; ?>
<div style="padding:0px 10px 0px 0px; float: right;">
<input id="fee_amt" class="fee_amt" type="text" placeholder="amt" name="fees_amt[]" >
</div> <br><br><?php
}?>
</div>
and my Javascript
$(document).ready(function(){
$('#fee_name').click(function() {
$('#fee_amt').prop('disabled', !$(this).is(':checked'));
});
});
but it worked on only the first checkbox. Anyone can tell my what can i do for others???
All your text fields that are enabled/disabled have the same id. Try to set a different id inside the loop and in your javascript enable the one according to the checkbox that is checked.
Another way (without using ids) is to set the data attribute in each checkbox:
<div class="my">
<?php $i = 1; ?>
<?php while ($ass = mysql_fetch_array($rs)) { ?>
<input type="checkbox" name="fees_name[]" class="fee_name" data-mycheckbox="<?php echo $i; ?>" value="<?php echo $ass['fees_name']; ?>" onclick='toggleReadonly(this)'>
<?php echo $ass['fees_name']; ?>
<div style="padding:0px 10px 0px 0px; float: right;">
<input id="fee_amt<?php echo $i; ?>" class="fee_amt" type="text" placeholder="amt" name="fees_amt[]" >
</div> <br><br><?php
$i++;
}?>
</div>
And in your js script:
$(document).ready(function(){
$(".fee_name").click(function(event) {
var identifier = $(this).data('mycheckbox');
var input_identifier = "#fee_amt" + identifier;
$(input_identifier).prop('disabled', !$(this).is(':checked'))
});
});
solution by #eyetea also solves the problem with your non-unique ids.
just in case you don't want to rely on any ids:
$(document).ready(function(){
$('input[name="fees_name\\[\\]]"').click(function() {
$(this).next().children(':first').prop('disabled', !$(this).is(':checked'));
});
});
note that this sort of selecting the elements heavily relies on your dom structure and has to be changed accordingly when your html changes.
Here is the working code what you need,
$( "input[type=checkbox]" ).on( "click", function(){
if($(this).is(':checked')) {
$(this).next().prop('disabled', false);
} else {
$(this).next().prop('disabled', true);
}
});
HTML
<input type="checkbox" name="fees_name[]">
<input type="text" disabled="disabled" /><br/>
<input type="checkbox" name="fees_name[]">
<input type="text" disabled="disabled" /><br/>
<input type="checkbox" name="fees_name[]" >
<input type="text" disabled="disabled" /><br />
<input type="checkbox" name="fees_name[]">
<input type="text" disabled="disabled" /><br />
<input type="checkbox" name="fees_name[]">
<input type="text" disabled="disabled" />
JSFIDDLE
If you need to give name then you could use input[name='fees_name[]']as,
$( "input[name='fees_name[]']" ).on( "click", function(){
if($(this).is(':checked')) {
$(this).next().prop('disabled', false);
} else {
$(this).next().prop('disabled', true);
}
});
JSFIDDLE
Use the following code-
<div class="my"><?php
$i=0;
while ($ass = mysql_fetch_array($rs)) {$i++;?>
<input type="checkbox" name="fees_name[]" id="fee_name[<?php echo $i?>]" value="<?php echo $ass['fees_name']; ?>" onChange='if(this.checked){toggleReadonly(this,true);} else{toggleReadonly(this,false)}'>
<?php echo $ass['fees_name']; ?>
<div style="padding:0px 10px 0px 0px; float: right;">
<input id="fee_amt[<?php echo $i?>]" class="fee_amt" type="text" placeholder="amt" name="fees_amt[]" readonly>
</div> <br><br><?php
}?>
JavaScript code
function toggleReadonly(chk_element, status)
{
chk_element_no=chk_element.id.substring(chk_element.id.indexOf('[')+1, chk_element.id.indexOf(']'));
txt_element_id="fee_amt["+chk_element_no+"]";
if(status==true)
document.getElementById(txt_element_id).readOnly=false;
else
document.getElementById(txt_element_id).readOnly=true;
}
check this fiddle.
Check the following similar sample code and execute it-
1.php
<html>
<head>
<script>
function toggleReadonly(chk_element, status)
{
chk_element_no=chk_element.id.substring(chk_element.id.indexOf('[')+1, chk_element.id.indexOf(']'));
txt_element_id="fee_amt["+chk_element_no+"]";
if(status==true)
document.getElementById(txt_element_id).readOnly=false;
else
document.getElementById(txt_element_id).readOnly=true;
}
</script>
</head>
<body>
<div class="my"><?php
$i=0;
while ($i++<=10) {?>
<input type="checkbox" name="fees_name[]" id="fee_name[<?php echo $i;?>]" value="<?php echo $i; ?>" onChange='if(this.checked){toggleReadonly(this,true);} else{toggleReadonly(this,false)}'>
<?php echo $i; ?>
<div style="padding:0px 10px 0px 0px; float: right;">
<input id="fee_amt[<?php echo $i;?>]" class="fee_amt" type="text" placeholder="amt" name="fees_amt[]" readonly>
</div> <br><br><?php
}?>
</div>
</body>
</html>

Categories