0

Guys, I know its easy to do it, but I'm having a hard time doing it. Please help me, I want to get the checked items in checkbox. The problem is that it gets the last value of it. I just used echo to get all the values, but how I can get all the values checkedd without using echo, and stored it in another variable. Thank You!

this is the html code

<input type="checkbox" name="sch[]" id="ra" <?php if(isset($sch)) echo "checked"?> value="sample a"/><label>ra sample</label><br><br>
    <input type="checkbox" name="sch[]" id="rb" <?php if(isset($sch)) echo "checked"?>  value="sample b" /><label>rb sample</label><br><br>
    <input type="checkbox" name="sch[]" id="rc" <?php if(isset($sch)) echo "checked"?>  value ="sample c"/><label>rc sample</label><br><br>

    <input type="checkbox" name="sch[]" id="rd" <?php if(isset($sch)) echo "checked"?> value="sample d/><label>rd sample</label><br><br>
    <input type="checkbox" name="sch[]" id="re" <?php if(isset($sch)) echo "checked"?> value="sample e"/><label>re sample</label><br><br>
    <input type="checkbox" name="sch[]" id="rf" <?php if(isset($sch)) echo "checked"?>  onclick="txtShow('txtOSchProg')"/><label>others</label><br><br>

this is the php code

for($i=0;$i<$n; $i++)
{
    $sch = $_SESSION['schp'][$i]. "; ";
    echo $sch;
}

Edited by bLuEmEzzy: wrong value

2
Contributors
2
Replies
19
Views
3 Years
Discussion Span
Last Post by bLuEmEzzy
1

Will you be able to post the 'txtShow' function too?
Where do you update the $_SESSION['schp'] variable?
If you are trying to do a string concatanation in the for loop, you are missing the '.' before the equal sign.
$sch .= $_SESSION['schp'][$i]. "; ";

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.