1,105,208 Community Members

Displaying an item depending on the users' selection

Member Avatar
Webville312
Posting Whiz
363 posts since Feb 2012
Reputation Points: 14 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

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>
Member Avatar
jstfsklh211
Junior Poster
155 posts since Apr 2011
Reputation Points: 38 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 2 [?]
 
0
 

what problem are you having

Member Avatar
diafol
Where are my eyes?
12,943 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,845 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

Why is this PHP? Need it moved to JS?

Member Avatar
Webville312
Posting Whiz
363 posts since Feb 2012
Reputation Points: 14 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

@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.

Member Avatar
Webville312
Posting Whiz
363 posts since Feb 2012
Reputation Points: 14 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Webville312
Posting Whiz
363 posts since Feb 2012
Reputation Points: 14 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Question Answered as of 11 Months Ago by diafol and jstfsklh211
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article