unable to get the value of the text field with the help of respective checkboxes. please help <p>I've a doubt. I've 3 textboxes and each is having checkboxes next to it. I want to display the values of only those textboxes whose respective checkboxes are clicked. Following is the attached HTML and PHP codes:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="f" method="post" action="4.php"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt; Facility &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="a1" value="a"&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="checkbox" id="facility[]" name="facility[]" value="Hostel"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="b1" value="b"&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="checkbox" id="facility[]" name="facility[]" value="Transport"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="c1" value="c"&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="checkbox" id="facility[]" name="facility[]" value="Food"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3"&gt;&lt;input type="submit" value="submit" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and below is the PHP part.</p> <pre><code>&lt;?php $a=$_POST['a1']; $b=$_POST['b1']; $c=$_POST['c1']; $facilityArray = $_POST['facility']; $facility = ""; if(count($facilityArray) &gt; 0) { foreach($facilityArray as $fac) { $facility .= " " . $fac; } } echo $facility; echo "&lt;br&gt;"; echo $a; echo "&lt;br&gt;"; echo $b; echo "&lt;br&gt;"; echo $c; ?&gt; </code></pre> <p>With the help of following codes I am able to display all the values of checked checkboxes. I am also able to display the values of all the textboxes. But I actually want to display the values of only those textboxes whose respective checkboxes are clicked. I know it may be a very basic question but please help me grow in PHP. Thanks in advance... :(</p>