Unable to retrieve id from dropdown

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agarwalsrushti
    New Member
    • Feb 2008
    • 63

    Unable to retrieve id from dropdown

    Hi,
    Ive made dynamic drop down boxes. On selection of value from first drop down box the values in second drop down are displayed. I ve made this two drop down in a separate file. I want to store the id value of the selected name in the drop down into database. I am able to store the value of first drop down but the value of second drop down is always saved as 0 in the database.
    I think its just a small error im am making somewhere. I think the change has to be made on line 232 in insert statement of process.php file
    I ve given the code of both my files below plz let me know how it can be fixed.
    Attached Files
    Last edited by agarwalsrushti; Mar 12 '08, 11:22 AM. Reason: could not be viewed
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You only need to include the relevant code.
    You've supplied too much.

    Comment

    • agarwalsrushti
      New Member
      • Feb 2008
      • 63

      #3
      Heres the relevant code i think where the change needs to be done.
      This is the code for drop down box.

      [code=php]
      <?php

      require "config.php "; // database connection details
      echo "

      function fillQualificati on(){
      // this function is used to fill the Qualification list on load

      ";

      $q1=mysql_query ("select * from qualification") ;
      echo mysql_error();
      while($nt1=mysq l_fetch_array($ q1)){
      echo "addOption(docu ment.form1.Qual ification, '$nt1[QualificationId]', '$nt1[QualificationNa me]');";
      }// end of while
      ?>
      } // end of JS function

      function SelectSpecial() {
      // ON or after selection of qualification this function will work

      removeAllOption s(document.form 1.Specializatio n);
      addOption(docum ent.form1.Speci alization, "", "-Select-", "");

      // Collect all element of Specialization for various QualificationId

      <?php
      // let us collect all QualificationId and then collect all Specialization for each QualificationId
      $q2=mysql_query ("select distinct(Qualif icationId) from specialization" );
      // In the above query you can collect QualificationId from qualification table also.
      while($nt2=mysq l_fetch_array($ q2)){
      echo "if(document.fo rm1.Qualificati on.value == '$nt2[QualificationId]'){";
      $q3=mysql_query ("select SpecializationA rea from specialization where QualificationId ='$nt2[QualificationId]'");
      while($nt3=mysq l_fetch_array($ q3)){
      echo "addOption(docu ment.form1.Spec ialization,'$nt 3[SpecializationI d]', '$nt3[SpecializationA rea]');";


      } // end of while loop
      echo "}"; // end of JS if condition

      }
      ?>
      }
      [/code]

      This is the insert statement from where the details go in database.
      [code=php]
      mysql_query("IN SERT INTO $db_table1(User Name,PhoneNo,Mo bileNo,YearsExp ,MonthsExp,Func tionalArea,KeyS kills,Qualifica tion,Specializa tion,Institute, FunctionalRoles ,CurrentEmploye r,PreviousEmplo yers,ProfileTit le,ResumeFile) values ('$_POST[UserName]','$_POST[PhoneNo]','$_POST[MobileNo]','$_POST[YearsExp]','$_POST[MonthsExp]','$_POST[AreaName]','$_POST[KeySkills]','$_POST[Qualification]','$_POST[Specialization]','$_POST[InstituteName]','$_POST[RoleName]','$_POST[CurrentEmployer]','$_POST[PreviousEmploye rs]','$_POST[ProfileTitle]','$_POST[ResumeFile]')")
      or die(mysql_error ());
      [/code]

      Comment

      Working...