Hello to everyone!

I'm kind of stumped on a problem with coding nested checkboxes.
Here's my situation, I have a checkbox similar to the one below. When the box is checked it should ask for additional data by presenting an additional field in this case labeled City for the city in which to conduct a utility check against.

<input type="checkbox" name="uc" value="ON" style="font-weight: 700"></font><b><font color="#000080" size="2">Utility Check</font></b>

Any feedback is appreciated.

Thank you all and have a great weekend!

    If you only want the additional field to show if the check box is clicked, then you need to use JavaScript, not PHP, to do that. Since PHP is a server-side language, everything that it does requires a page refresh. JavaScript, on the other hand, is a client-side language, and so can do things like that.

    If you want the additional field to always show, and then check to see if it has a value when the form is submitted, then you can check that on the page where the form data is sent to, by doing a

    if (isset($_POST['City'])) {
    //do this;
    }

      This is what it looks like, I didn't notice html off. I have attached an screenshot of the checkbox. When selected it should show a nested field to place a value for the City to run the check against.

      Thanks to all.

        Well, that is not exactly what I'm looking for, the checkbox is Utility Check when a user checks the box a field labled city should display allowing the user to fill-in the field. In the scenario you described, the value is like grayed out or always active and then I run the code you suggested so it can update like a dbsubsearch table that I have to indicate there was a value present. I figured that I could also have like a collapsable field like when I click on the word Utility Check it would display the field and I could fill it in. However the Utility field should not be hot if the checkbox for it is not selected thereby not displaying the collapsable field of City.

          You'd need to use javascript to make the field appear when the click on the checkbox. I'm not all that knowledgeable in javascript (I hope to learn it soon...), but I believe you would need to put an onClick=somefunction() into the <input > tag. somefunction() would then need to check and see if another input tag is visible or not, and then display it or hide it, depending. You can see if there's an example that you can learn from here: http://www.w3schools.com/dhtml/dhtml_examples.asp

            Well first, let me thank bbreslauer for his input. It was helpful.

            Well found a great site for working with javascript in regards to checkboxes, textboxes, just about anything and it includes alot of code with nested values.

            Solved my problem in about an hour. Now to program the logic for the backend

            The site is : http://www.faqts.com/knowledge_base/index.phtml/fid/310

            Laters,

            jchapa

              Write a Reply...