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
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to implement server side field validation and display customized error messages to the client.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The viewer will learn how to dynamically set the form action using jQuery.

707 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