473,385 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Show/ hide dynamic combobox

I have two comboboxes which are generated by queries from mysql.

When user choose value in first combobox i need to display second combobox, but if nothing is choosen second combox should not be displayed.
The code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "<form method= \"post\" name=\"formcombo\" action=''>";
  3. echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Choose main category</option>";
  4. while($cat2 = mysql_fetch_array($query2)) {
  5. if($cat2['category_id']==@$category)
  6. {
  7. echo "<option value='$cat2[category_id]'>$cat2[category_name]</option></br>";}
  8. else
  9. {
  10. echo "<option value='$cat2[category_id]'>$cat2[category_name]</option>";
  11. }
  12. }
  13. echo "</select></br>";
  14. echo "<select name='subcat'><option value=''>Choose subcategory</option>";
  15. while($cat = mysql_fetch_array($query1)) {
  16. echo "<option value='$cat[subcat_name]'">$cat[subcat_name]</option>";
  17. }
  18. echo "</select>";
  19. echo "<input type=\"submit\" value =\"Submit\">";
  20. echo "</form>";
  21. ?>
  22.  
I use javascript to generate combobox values:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function reload(form){
  3. var val=form.cat.options[form.cat.options.selectedIndex].value;
  4. self.location='main.php?cat=' + val ;
  5. }
  6. </script>
  7.  
Jul 26 '11 #1
1 2680
Rabbit
12,516 Expert Mod 8TB
I don't see where you're trying to show or hide the combo box. Also, in your PHP file, you're not defining your queries anywhere. And if you're trying to make "dynamic" combo boxes, ie the values in one combo box change in accordance to the value in another combo box, then you should look into AJAX.
Jul 26 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Harry | last post by:
I want to provide a drill down facility for the users - the plan is to intially display a table with summary rows containing results of previous selected search criteria. In each summary row you...
2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
3
by: alex | last post by:
I'd like to have a show/hide widget on my web site, kind of like "show details" / "hide details" in Google Groups. Is there a tutorial explaining how to make them? Google's is a bit complex and...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
1
by: shankwheat | last post by:
I'm creating a dynamic table with asp and I would like to add a "Show All" and "Collapse All" feature to show/hide certain rows within the table. This code works well for showing/hiding one row at...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
0
by: Davilean | last post by:
Hi, I have got a combobox which directs to another page on select and when the submit button is clicked. I am trying to change it into a dynamic combobox which redirects you to another page on...
1
by: prathna | last post by:
Hi .. I have a logic:iterate tag which will display 5 rows each row with a drop downlist and 2 textfields.now by default all the rows will be shown.how do i hide all the rows except the first...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.