473,395 Members | 1,577 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,395 software developers and data experts.

dependent multiple list menu

25
Hello,
I have a problem. I need to do multiple list menu which is populate each other when selected.
The problem is my code run perfect on my localhost server but when i upload to the server the code seem not too worked. it not update the result.

For example if i select category A it should list out sub category A that is A1 and A2. But, the result is it list out A1, A2 and A3 even i already remove A3 subcategory. So, for me it not update the result. Please help me how to modify this code so that it can run smoothly on the server.

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function getXMLHTTP() { //fuction to return the xml http object
  3.         var xmlhttp=false;    
  4.         try{
  5.             xmlhttp=new XMLHttpRequest();
  6.         }
  7.         catch(e)    {        
  8.             try{            
  9.                 xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
  10.             }
  11.             catch(e){
  12.                 try{
  13.                 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  14.                 }
  15.                 catch(e1){
  16.                     xmlhttp=false;
  17.                 }
  18.             }
  19.         }
  20.  
  21.         return xmlhttp;
  22.     }
  23.     function getmodel(strURL) {        
  24.  
  25.         var req = getXMLHTTP();
  26.  
  27.         if (req) {
  28.  
  29.             req.onreadystatechange = function() {
  30.                 if (req.readyState == 4) {
  31.                     // only if "OK"
  32.                     if (req.status == 200) {                        
  33.                         document.getElementById('modeldiv').innerHTML=req.responseText;                        
  34.                     } else {
  35.                         alert("There was a problem while using XMLHTTP:\n" + req.statusText);
  36.                     }
  37.                 }                
  38.             }            
  39.             req.open("GET", strURL, true);
  40.             req.send(null);
  41.         }                
  42.     }
  43. </script> 
  44.  
  45.  
  46. <form name="testform" action="insert_product.php" method="post" enctype="multipart/form-data" onsubmit="return checkform(this);"> 
  47.  
  48. <select name="category" onChange="getmodel('populate.php?category='+this.value)">
  49.         <option value='-1'>Select Category</option>
  50.         <?
  51.         $q=mysql_query("select * from category where main_category_id = '1' ORDER BY category ASC ");
  52.         while($n=mysql_fetch_array($q)){
  53.         echo "<option value=$n[category_id]>$n[category]</option>";
  54.         }
  55.         ?>
  56.         </select>
  57.  
  58.  
  59. <div id="modeldiv">
  60.         <select name="model">
  61.         <option>Select model</option> 
  62.         </select>
  63.         </div>
  64. </form>
  65.  
  66.  
  67.  
  68. //populate.php code
  69.  
  70. <? $category=$_REQUEST['category'];
  71. include("db.inc");
  72. mysql_select_db('lenhoe');
  73. $query="select * from model where category_id=$category";
  74. $result=mysql_query($query);
  75.  
  76. ?>
  77. <select name="model">
  78. <option>Select model</option>
  79. <? while($row=mysql_fetch_array($result)) { ?>
  80. <option value="<?=$row['model_id']?>"><?=$row['model']?></option>
  81. <? } ?>
  82. </select>
  83.  
  84.  
Jul 1 '10 #1
1 2073
dlite922
1,584 Expert 1GB
If your program runs on one machine, but not another, then it's not a problem with your code but with the server and/or configuration differences between the machines.



Dan
Jul 1 '10 #2

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

Similar topics

1
by: 234 | last post by:
Please help. I'm first start to use javascript but I don't know how to develop the captioned. e.g. <select name="select" onChange="change(this.options.selectedIndex)"> <option...
2
by: Nick | last post by:
Is it possible through css to make an element in a multiple list menu unselectable. Im organizing my list by using titles... +-------------+ | CATEGORY 1 | | option 1 | | option 2 | | ...
1
by: paakwesi | last post by:
I'm looking to modify the javascript behavior on http://research.yale.edu/%7Ekamusi/exercises/learners/index.php to do two things: Initial State: Both menus are populated with all their entries...
4
by: Brian | last post by:
How can I use javascript to select Items in a List/Menu? For example: (value1, value2) will select value1 and value2 in a list menu....
2
by: computer_angel | last post by:
can someone help me pls.... how to get the value from the mysql when using two drop down that is dependent to the first? For example....(online enrolment) department then the other dropdown...
1
by: platostoteles | last post by:
Hallo NG, I am new to JavaScript and would really appreciate any help to solve my problem. I am using the blow code in my form to validate form fields. What I would like to accomplish is that...
2
by: webfreak | last post by:
hello am a relative newbie to php. am using dreamweaver,php/mysql. i want to populate a mysql field using a multiple selection list menu. i have been to countless forums and so far nothing. can...
4
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be...
1
by: amel86 | last post by:
hello everybody, i have a problem in my system related to list menu dependent. i want a simple list menu dependent that when we select A, it show B, when select B it show C and so on. If...
1
by: amel86 | last post by:
hello.. i have a question about how to make dependent list menu based on mysql? actually, i already found some code that helped me a lot but there has a problem that is i want to change 'get'...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.