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

chain select error undefined index

232 100+
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 1168

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

Similar topics

3
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...
15
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...
5
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 : ...
1
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....
10
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...
1
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...
4
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...
1
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"...
10
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.