Jump to content

How to reterive check box info


kks_krishna

Recommended Posts

 

HI,

 

I have added 10 check boxhes in my html form. When I am submit the form it will be taken to info.php page.Now i want to get all the check boxes selected. How can I do that in PHP?

 

 

 

first try to be clear is typographical or grammatical joke  ;D

any ways use the post method

$_POST['name of text box here'];

 

and by the way are u using array on that chk box

Link to comment
Share on other sites


<form name="add_links" action="add_link.html">
	<?php include("templates/link_header.php"); ?>
	<div id="contents">
		<table>
			<tr>
				<td class="text_format">
					Link Text
					<?php  
						foreach($labels as $value)
						{
							echo $value;
						}
					?>
				</td>
				<td >
					<input type="text" size="30" name="link_text">
				</td>
			</tr>
			<tr>
				<td class="text_format">
					Link URL
				</td>
				<td>
					<input type="text" size="30" name="link_url">
				</td>
			</tr>
			<tr>
				<td class="text_format">
					Description
				</td>
				<td>
					<textarea rows="10" cols="40" name="link_desc"></textarea>
				</td>
			</tr>
			<tr>
				<td class="text_format">
					Label
				</td>
				<td>
					<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>
					<input type="checkbox" name="labels" value="jsp">JSP
					<input type="checkbox" name="labels" value="servlets">Servlets
					<input type="checkbox" name="labels" value="ejb">EJB
					<input type="checkbox" name="labels" value="jta">JTA
					<input type="checkbox" name="labels" value="jms">JMS
					<input type="checkbox" name="labels" value="jni">JNI<br>
					<input type="checkbox" name="labels" value="stripes">Stripes
					<input type="checkbox" name="labels" value="tapestry">Tapestry
					<input type="checkbox" name="labels" value="wicket">Wicket
					<input type="checkbox" name="labels" value="eclipse">Eclipse
					<input type="checkbox" name="labels" value="netbeans">NetBeans
					<input type="checkbox" name="labels" value="faqs">Interview Questions<br>
					<input type="checkbox" name="labels" value="java5">Java 5.0
					<input type="checkbox" name="labels" value="java6">Java 6.0
					<input type="checkbox" name="labels" value="java7">Java 7.0
					<input type="checkbox" name="labels" value="scjp">SCJP
					<input type="checkbox" name="labels" value="scwcd">SCWCD
					<input type="checkbox" name="labels" value="scbcd">SCBCD<br>
					<input type="checkbox" name="labels" value="scja">SCJA
					<input type="checkbox" name="labels" value="scdjws">SCDJWS
					<input type="checkbox" name="labels" value="scea">SCEA
				</td>
			</tr>
			<tr>
				<td>
					<input type="submit" onclick="return validateLink()" value="Submit">
				</td>
			</tr>
		</table>

 

<?php
		$link_text = $_GET['link_text'];
		$link_url_id = "";
		$link_url = $_GET['link_url'];
		$link_desc = $_GET['link_desc'];
		$link_tag = $_GET['link_tag'];
		$labels = array();
		$this->$labels = $_GET['labels'];	
                          foreach($labels as $value)
						{
							echo $value;
						}	

?>

Link to comment
Share on other sites

All these...

 

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

 

Need to be....

 

<input type="checkbox" name="labels[]" value="spring">Spring

 

Then...

 

<?php

  foreach($_GET['labels'] as $value) {
    echo $value;
  }

?>

Link to comment
Share on other sites

HI,

 

Now i got the problem. Its working. The problem is i am using URL rewriting. so its not able to get the values. Do you have any idea how to get the values when doing URL rewriting.

 

basically file name is add_link.php.

after url re wrting it is add_link.html

 

Please help me.

Link to comment
Share on other sites

 

HI,

 

What is the problem if i am using the checkbox name without "[]". PHP is taking values only when we are using the "[]". but javascript is not working. so I have removed []. Please help me how to fix this problem.

 

<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>
			<input type="checkbox" name="labels" value="jsp">JSP

 

foreach($_GET['labels'] as $value) 
			{
				echo $value;
			}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.