Solved

show / hide table row if select menu equals 1

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now