473,549 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

chain select error undefined index

232 New Member
i am trying to use chain select on a form
i am facing two problems
  1. dept is fetching branch but branch is not fetching designations.
  2. same form is not posting all three dropdowns and therefore insert not possible as it is showing error.
    Notice: Undefined index: branch in C:\xampp\htdocs \w.php on line 35

    Notice: Undefined index: desg in C:\xampp\htdocs \w.php on line 36
    2---------------------------/-------------------------------------------/----------------




w.php
Expand|Select|Wrap|Line Numbers
  1.  <html>
  2. <head>
  3. <script>
  4. function showUser(str) {
  5.     if (str == "") {
  6.         document.getElementById("txtHint").innerHTML = "";
  7.         return;
  8.     } else {
  9.         if (window.XMLHttpRequest) {
  10.             // code for IE7+, Firefox, Chrome, Opera, Safari
  11.             xmlhttp = new XMLHttpRequest();
  12.         } else {
  13.             // code for IE6, IE5
  14.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  15.         }
  16.         xmlhttp.onreadystatechange = function() {
  17.             if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  18.                 document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
  19.             }
  20.         }
  21.         xmlhttp.open("GET","x.php?q="+str,true);
  22.         xmlhttp.send();
  23.     }
  24. }
  25.  
  26. </script>
  27. </head>
  28. <body>
  29. <?php
  30. require_once('includes/load.php');
  31.  if(isset($_POST['add_file'])){
  32.     // echo"kkshan";
  33.      //exit;
  34.      $f_dept  = strtoupper(remove_junk(real_escape($_POST['dept'])));
  35.       $f_branch  = strtoupper(remove_junk(real_escape($_POST['branch'])));
  36.        $f_desg  = strtoupper(remove_junk(real_escape($_POST['desg'])));
  37.       echo $f_dept."---------------------------/----------------".$f_branch ."---------------------------/----------------".$f_desg;
  38.       //i want to insert these in database
  39.  
  40.  }else{//echo"kkshan";
  41.      //exit;
  42.  
  43. ?>
  44.  <form method="post" class="clearfix">
  45. <select name="dept" onchange="showUser(this.value)">
  46.   <option value="">Select a dept:</option>
  47.   <option value="1">XXX</option>
  48.   <option value="2">YYY</option>
  49.   <option value="3">OTHERS</option>
  50.  
  51.   </select>
  52.  
  53.   <TD><button type="submit" name="add_file" class="btn btn-info pull-right">Add file</button></TD></TR>
  54. </form>
  55. <br>
  56. <div id="txtHint"><b>Person info will be listed here...</b></div>
  57.  <?php } ?>
  58. </body>
  59. </html>
x.php
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <script>
  5. function xxx(str) {
  6.     if (str == "") {
  7.         document.getElementById("txtHint").innerHTML = "";
  8.         return;
  9.     } else {
  10.         if (window.XMLHttpRequest) {
  11.             // code for IE7+, Firefox, Chrome, Opera, Safari
  12.             xmlhttp = new XMLHttpRequest();
  13.         } else {
  14.             // code f    or IE6, IE5
  15.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  16.         }
  17.         xmlhttp.onreadystatechange = function() {
  18.             document.write("kkshan");
  19.             if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  20.                 document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
  21.             }
  22.         }
  23.         xmlhttp.open("GET","z.php?q="+str,true);
  24.         xmlhttp.send();
  25.     }
  26. }
  27. </script>
  28. </head>
  29. <body>
  30.  
  31. <?php
  32.  require_once('includes/load.php');
  33. $q = $_GET['q'];
  34. //echo $q;
  35. //exit;
  36. if ($q=="1"){$q=" branch between '01' and '50'";}
  37. elseif ($q=="2"){$q=" branch between '51' and '88'";}
  38. else{$q=" 1=1";}
  39.  
  40. $sql="SELECT * FROM branch WHERE ".$q." and brname<>' '";
  41. //ECHO $sql;
  42. //EXIT;
  43. $result = mysqli_query($con,$sql);
  44. ?>
  45.  
  46. </head>
  47. <body>
  48.  
  49. <form method="post" class="clearfix">
  50. <select name="branch" onchange="xxx(this.value)">
  51.  <option value="">Select a branch:</option>
  52.  
  53.  <?php
  54.  
  55. while($file = mysqli_fetch_array($result)) {
  56.     ?>
  57.  
  58.   <option value="<?php echo $file['BRANCH'];?>"><?php echo $file['BRNAME'];?></option>
  59.   <?PHP
  60.     }
  61.  
  62. mysqli_close($con);
  63. ?>
  64. </select>
  65. </form>
  66. </body>
  67. </html>
z.php
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4.  
  5. <?php
  6.  
  7.  require_once('includes/load.php');
  8. $q =$_GET['q'];
  9.  
  10.  
  11.  
  12. $sql="SELECT * FROM maymst WHERE branch='".$q."'";
  13. //ECHO $sql;
  14. //EXIT;
  15. $result = mysqli_query($con,$sql);
  16. ?>
  17.  
  18.  <select name="staff">
  19.  <option value="">Select a person:</option>
  20.  
  21.  <?php
  22.  
  23. while($file = mysqli_fetch_array($result)) {
  24.     ?>
  25.  
  26.   <option value="<?php echo $file['DESG'];?>"><?php echo $file['DESG'];?></option>
  27.   <?PHP
  28.     }
  29. mysqli_close($con);
  30. ?>
  31. </select>
  32. </body>
  33. </html>
Oct 11 '15 #1
0 1180

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

Similar topics

3
4958
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined index: abdatum in /zipcode.php on line 13 Notice: Undefined index: zimmer in /zipcode.php on line 14 Notice: Undefined index: city in /zipcode.php...
15
4452
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about enased whitespace (to my best memory) AT other times I get an undefined index notice as below: Notice: Undefined index: last_reminder_id in...
5
7350
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : $http_ref= $HTTP_REFERER; $prog = $_COOKIE;
1
8932
Markus
by: Markus | last post by:
In the process of making a user registration page, and if a username and or email address is already in use i set a cookie then use header( ... to redirect the user back to the page with the form. On the page with the form, i check to see if there is reason to echo the error (if isset $_GET; .. ) And then echo the cookie out. Hooooowever, it...
10
1366
anfetienne
by: anfetienne | last post by:
i take information from a database and then have the collected values entered into a form with hidden fields. <input type="hidden" name="tempID" id="tempID" value='<?php print $random_digit;?>'/> <input type="hidden" name="htmlcss" id="htmlcss" value='<?php print $htmlcss;?>'/> <input type="hidden" name="header" id="header"...
1
6720
anfetienne
by: anfetienne | last post by:
i take information from a database and then have the collected values entered into a form with hidden fields. <input type="hidden" name="returnURL" id="returnURL" value="<?php print $returnURL;?>"/> <input type="hidden" name="tempID" id="tempID" value='<?php print $random_digit;?>'/> <input type="hidden" name="htmlcss"...
4
6284
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59 Notice: Undefined index: args in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92 Warning: Invalid argument supplied for...
1
1646
by: ghjk | last post by:
I'm developing a web site using php and mysql. This is my index.php page. <?php session_start(); require_once ('dbconnect.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <META http-equiv=Pragma content=no-cache> <head> <meta http-equiv="Content-Type"...
10
2288
by: fadhili | last post by:
<?php /*the points system for this Q&A has to be passed from question to question. We are going to do this by passing it in the URL. After the first question, the current score is passed through in the URL for the form POST,*/ $question1="
0
7451
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7473
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5369
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.