Solved

In php, I have four radio button and their values comes from while loop data comes from DB.I need add radio button's onclick one drop menu .

Posted on 2011-09-05
4
500 Views
Last Modified: 2012-05-12
In php, I have four radio button and their values comes from while loop data comes from DB.I need add radio button's onclick drop menu and drop down menu will change onclick radio button action .
0
Comment
Question by:shawnlearn
  • 2
4 Comments
 
LVL 7

Expert Comment

by:boon86
ID: 36483308
you need onChange="someaction();"
0
 
LVL 1

Author Comment

by:shawnlearn
ID: 36483436
<?php
$sqls = "SELECT * FROM `option_contents` WHERE `optiontype` = '1' AND `option_name_id` = '3'";
$runquery = mysql_query($sqls,$con);
    while($data = mysql_fetch_assoc($runquery))
    {
    ?>
    <input type="radio" name="Sauce3" value="<?php echo $data['value']; ?>"  onchange="showStuff('answer1'); return false;">
    <span><?php echo $data['value']; ?> </span><br/>
    <div id="answer1" style="display: none; margin-left:25px;">
        <select name="HDSIZE">
            <option selected="" value="500GBSATAHD">500 GB 7200 RPM SATA hard drive (+$0/month)</option>
            <option value="1000GBSATAHD">1TB 7200 RPM SATA hard drive (+$20/month)</option>
            <option value="2000GBSATA">2 TB SATA (5,900 rpm) (+$40/month)</option>
        </select>
    </div>
    <?php
     }
    ?>
This is my code. How is it mange or call i function . nOw i used static drop menu for testing after code working i will add dynamic code will use. Tell me how i do ?
0
 
LVL 11

Accepted Solution

by:
maeltar earned 250 total points
ID: 36483579
Using jQuery you can use this method

<script language=javascript type='text/javascript'>

$(document).ready(function(){
   $("#answer1").hide();
  $("input[name$='group_name']").click(function(){
 
  var radio_value = $(this).val();
 
  if(radio_value=='Yes') {
    $("#answer1").show("slow");

  }
  else if(radio_value=='No') {

    $("#answer1").hide();
   }
  });
 


 
});


</script>
</head>
 <body>
<form action="" method="post" name="form1">

  <p>

    <label>
      <input type="radio" name="group_name" value="Yes" id="group_name_0" />
      Yes</label>
    <label>
      <input type="radio" name="group_name" value="No" id="group_name_1" />
    No</label>
    <br />
  </p>

</form>

    
 <div id="answer1">
          <select name="HDSIZE">
            <option selected="" value="500GBSATAHD">500 GB 7200 RPM SATA hard drive (+$0/month)</option>
            <option value="1000GBSATAHD">1TB 7200 RPM SATA hard drive (+$20/month)</option>
            <option value="2000GBSATA">2 TB SATA (5,900 rpm) (+$40/month)</option>
        </select>

 </div>

Open in new window

0
 
LVL 1

Author Closing Comment

by:shawnlearn
ID: 36486843
Thank you for your help.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question