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
Solved

show / hide table row if select menu equals 1

Posted on 2010-11-22
4
370 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 167 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 167 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 166 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

856 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