combobox problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rohitrohitrohit
    New Member
    • Oct 2007
    • 18

    combobox problems

    new to php.....

    i hav a login page? after validaing loginname and password second page comes...... i access his loginname through url which is ->http://localhost/aa/vtr/add/add_ps2.php?nam e=div,in second page i hav three combobox (unit,achivemen ts,crop) these comboxbox dynamically fill values from mysql database depends on loginname but when i am selecting unit comboxbox value browser url changed to http://localhost/aa/vtr/add/add_ps2.php because of this other controls in my form show nothing or null.
    from rohit
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hey mate,

    Can you upload some code?

    /MK

    Comment

    • rohitrohitrohit
      New Member
      • Oct 2007
      • 18

      #3
      loginpage code->
      <form........ >
      <input name="txtuserna me" id="txtusername " type="text" width="70px" class="style23"/>
      <input name="txtpass" type="password" width="70px" class="style23"/>
      button here........... ........
      </form>

      i made a mid page for validating user code is below---

      <?php
      $divname=$_POST['txtusername'];
      $pass=$_POST['txtpass'];
      include("../dbcon.php");
      $dbcon1=new Dbcon();
      $host=$dbcon1->host;
      $user=$dbcon1->user;
      $pass1=$dbcon1->pass;
      $db=$dbcon1->db;
      mysql_connect($ host,$user,$pas s1) or die("could not connect:".mysql _error());
      mysql_select_db ($db);

      $query="select UserName,Passwo rd FROM user where UserName='$divn ame' and Password='$pass '";
      $result = mysql_query($qu ery);
      if($row = mysql_fetch_arr ay($result,MYSQ L_ASSOC))
      {
      header("Locatio n: homepage.php?na me=$divname");

      }
      else
      {
      ......
      }
      ?>
      after validating... second page come in this page i made some combobox. ----

      <?php
      $division=$_GET['name'];
      $res = mysql_query("SE LECT distinct untcode FROM div_gp where division='$divi sion'")or die("Invalid query: " . mysql_query());
      echo '<select class="style23" id="unt" name="unt" onchange="sel() ">';
      echo '<option value="">Select ..</option>';
      while ($row = mysql_fetch_arr ay($res))
      {
      $va1 = $row['untcode'];
      if(isset($_POST['unt']) )
      {
      if($va1==$_POST['unt'])
      {
      echo "<option value='$va1' selected>$va1</option>";
      }
      else
      {
      echo "<option value='$va1'>$v a1</option>";
      }
      }
      else
      {
      echo "<option value='$va1'>$v a1</option>";
      }
      }
      echo '</select>';
      ?>
      onchange this combobox value corresponding value fill to other combobox but browers url changes.is there anyway when in mypage whenever i change comboxbox value my browser url did not effected.

      Comment

      • gabosom
        New Member
        • Sep 2008
        • 9

        #4
        Hi,

        On the page where you have your combobox, is that all the code for that page? What does 'sel()' do?

        I would recommend that if want to fill the values of the other combobox, use an AJAX script or POST the data into the same page.

        Cheers

        Comment

        Working...