We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,434 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Displaying an item depending on the users' selection

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>
3
Contributors
5
Replies
3 Months
Discussion Span
1 Month Ago
Last Updated
9
Views
Question
Answered
Webville312
Posting Whiz
301 posts since Feb 2012
Reputation Points: 10
Solved Threads: 31
Skill Endorsements: 0

what problem are you having

jstfsklh211
Junior Poster
100 posts since Apr 2011
Reputation Points: 34
Solved Threads: 27
Skill Endorsements: 1

Why is this PHP? Need it moved to JS?

diafol
Keep Smiling
Moderator
10,839 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,536
Skill Endorsements: 61

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

Webville312
Posting Whiz
301 posts since Feb 2012
Reputation Points: 10
Solved Threads: 31
Skill Endorsements: 0

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

Webville312
Posting Whiz
301 posts since Feb 2012
Reputation Points: 10
Solved Threads: 31
Skill Endorsements: 0

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

Webville312
Posting Whiz
301 posts since Feb 2012
Reputation Points: 10
Solved Threads: 31
Skill Endorsements: 0
Question Answered as of 1 Month Ago by diafol and jstfsklh211

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0752 seconds using 2.73MB