Hullo,

I am working on sam php code that captures users' details, depending on their choice. If the user selects "No", then the products will not be delivered to him, and so; the form collecting details will not be displayed. However, if he selects "Yes" option, then the form to collect his details will be displayed, and he enters his details. Now, I have been able to do it using a radiobutton, but I want to do it using a select drop down menu, to save me sam space. Here is the code I have been working with;

First, the javascript;

<script type = "text/javascript" language = "Javascript">
    function Proof(obj) {
        if (document.getElementById('delivery').checked) {
            displayValue = "block";
        } else {
            displayValue = "none";
        }
        document.getElementById('make_delivery').style.display = displayValue;
    }

</script>

Then I have the radiobutton code;

<div align="left">
              <input name="delivery" type="radio" id="delivery" tabindex="1" value="yes" onchange="Proof(this);" /> 
              Yes
              <input name="delivery" type="radio" id="delivery" tabindex="2" value="no" onchange="Proof(this);" /> 
              No</div>

And then the code for the form capturing user input in case the user selects "yes";

  <div id="make_delivery" style="display:none;">
 <table width="228" border="0">
  <tr>
    <td width="72"><div align="left"><strong>Name:</strong></div></td>
    <td width="146"><div align="left">
      <input type="text" name="uname" id="uname" onblur="MM_validateForm('uname','','R');return document.MM_returnValue"/>
    </div></td>
  </tr>
  <tr>
    <td><div align="left"><strong>Location:</strong></div></td>
    <td><div align="left">
      <input type="text" name="location" id="location" onblur="MM_validateForm('location','','R');return document.MM_returnValue"/>
    </div></td>
  </tr>
  <tr>
    <td><div align="left"><strong>Contact:</strong></div></td>
    <td><div align="left">
      <input type="text" name="contact" maxlength="10" id="contact" onblur="MM_validateForm('contact','','RisNum');return document.MM_returnValue"/>
    </div></td>
  </tr>
</table>     
            </div>

what problem are you having

Member Avatar for diafol

Why is this PHP? Need it moved to JS?

@jstfsklh211, with that code, I am not having any problems. However what I want to do is to change the radiobutton to a drop down menu, because; the radiobutton is taking up too much space. I want it to be such that when a user select YES, a form is displayed for them to fill, and if they select NO, then the form stays hidden.

@diafol, Because, I am not using javascript entirely. It is embedded in my php script.

Thanx guyz, I got my way around it; and it worked ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.