Jump to content

Help needed for checkbox


kks_krishna

Recommended Posts

HI,

 

How to get the values when I am using the checkbox names filed without [].Its not workingf without using labels[]. But i dont want to use array symbol since its giving problem in JavaScript.

 

<input type="checkbox" name="labels" value="spring">Spring
			<input type="checkbox" name="labels" value="hibernate">Hibernate
			<input type="checkbox" name="labels" value="seam">JBoss Seam
			<input type="checkbox" name="labels" value="javafx">JavaFX
			<input type="checkbox" name="labels" value="jsf">JSF
			<input type="checkbox" name="labels" value="struts">Struts<br>

 

Link to comment
https://forums.phpfreaks.com/topic/59802-help-needed-for-checkbox/
Share on other sites

<form>

 

<input type="hidden" name="totcheckbox" value="6">

<input type="checkbox" name="labels0" value="spring">Spring

<input type="checkbox" name="labels1" value="hibernate">Hibernate

<input type="checkbox" name="labels2" value="seam">JBoss Seam

<input type="checkbox" name="labels3" value="javafx">JavaFX

<input type="checkbox" name="labels4" value="jsf">JSF

<input type="checkbox" name="labels5" value="struts">Struts<br>

 

</form>

 

when post

for($i=0;$i<$_POST['totcheckbox'];$i++){

        if(isset($_POST['labels'.$i])){

        }

}

<form>

 

<input type="hidden" name="totcheckbox" value="6">

<input type="checkbox" name="labels0" value="spring">Spring

<input type="checkbox" name="labels1" value="hibernate">Hibernate

<input type="checkbox" name="labels2" value="seam">JBoss Seam

<input type="checkbox" name="labels3" value="javafx">JavaFX

<input type="checkbox" name="labels4" value="jsf">JSF

<input type="checkbox" name="labels5" value="struts">Struts

 

 

</form>

 

when post

for($i=0;$i<$_POST['totcheckbox'];$i++){

        if(isset($_POST['labels'.$i])){

        }

 

Thats great. Now I want pass it as array to other method. bcos that method already takes only array. How can i set all the values into single array?

when post to next page

 

$set_checked_labels_array = array();

for($i=0;$i<$_POST['totcheckbox'];$i++){

        if(isset($_POST['labels'.$i])){

 

            $set_checked_labels_array[] = $_POST['labels'.$i];

        }

}

 

echo " < pre> ";

echo "checked labels";

print_r($set_checked_labels_array);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.