?
Solved

show / hide table row if select menu equals 1

Posted on 2010-11-22
4
Medium Priority
?
374 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
[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
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:jmatix
jmatix 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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

770 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