Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

show / hide table row if select menu equals 1

Posted on 2010-11-22
4
Medium Priority
?
376 Views
Last Modified: 2012-05-10
How can I only show a table row based on the the value of the attached select menu being 1. i.e. So if the value is not 1 it should hide the table row?

Select menu code attached.
<select name="ink_brand_id" id="ink_brand_id">
        <?php
do {  
?>
        <option value="<?php echo $row_rs_ink_brand['id']?>"><?php echo $row_rs_ink_brand['ink_brand']?></option>
        <?php
} while ($row_rs_ink_brand = mysql_fetch_assoc($rs_ink_brand));
  $rows = mysql_num_rows($rs_ink_brand);
  if($rows > 0) {
      mysql_data_seek($rs_ink_brand, 0);
        $row_rs_ink_brand = mysql_fetch_assoc($rs_ink_brand);
  }
?>
      </select>

Open in new window

0
Comment
Question by:petewinter
4 Comments
 
LVL 10

Accepted Solution

by:
effx earned 668 total points
ID: 34188446
You can use jQuery to do this.

http://api.jquery.com/hide/
0
 
LVL 16

Assisted Solution

by:Justin Mathews
Justin Mathews earned 668 total points
ID: 34189440
Assuming the table row to show/hide <tr> has an id='row1'. Add an onchange hander to your <select> element as:

<select name="ink_brand_id" id="ink_brand_id" onchange="showhiderow(this)">

then define the JS function showhiderow() as:
function showhiderow(sel)
{
 var disp = sel.options[sel.selectedIndex].value=='1'?'':'none';
 document.getElementById('row1').style.display = disp;
}

Open in new window

0
 
LVL 6

Assisted Solution

by:Codebot
Codebot earned 664 total points
ID: 34189492
you can use this simple plugin
or
simple you can use this
http://www.developerbuzz.com/2008/10/use-jquery-to-show-and-hide-part-of.html
0
 

Author Closing Comment

by:petewinter
ID: 34200680
Many Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

886 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