Solved

show / hide table row if select menu equals 1

Posted on 2010-11-22
4
373 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

729 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