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
491 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

WordPress is constantly evolving, and with each evolution appears to get better and better.  One of the big drawbacks prior to version 3 was that there was no way to be able to set up a custom menu from the backend. The Old Way Adding menus is…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The viewer will learn how to dynamically set the form action using jQuery.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now