Unable to retrieve id from dropdown | Member | | Join Date: Feb 2008
Posts: 63
| | |
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.
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,938
| | | re: Unable to retrieve id from dropdown
You only need to include the relevant code.
You've supplied too much.
| | Member | | Join Date: Feb 2008
Posts: 63
| | | re: Unable to retrieve id from dropdown
Heres the relevant code i think where the change needs to be done.
This is the code for drop down box. -
<?php
-
-
require "config.php"; // database connection details
-
echo "
-
-
function fillQualification(){
-
// this function is used to fill the Qualification list on load
-
-
";
-
-
$q1=mysql_query("select * from qualification");
-
echo mysql_error();
-
while($nt1=mysql_fetch_array($q1)){
-
echo "addOption(document.form1.Qualification, '$nt1[QualificationId]', '$nt1[QualificationName]');";
-
}// end of while
-
?>
-
} // end of JS function
-
-
function SelectSpecial(){
-
// ON or after selection of qualification this function will work
-
-
removeAllOptions(document.form1.Specialization);
-
addOption(document.form1.Specialization, "", "-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(QualificationId) from specialization");
-
// In the above query you can collect QualificationId from qualification table also.
-
while($nt2=mysql_fetch_array($q2)){
-
echo "if(document.form1.Qualification.value == '$nt2[QualificationId]'){";
-
$q3=mysql_query("select SpecializationArea from specialization where QualificationId='$nt2[QualificationId]'");
-
while($nt3=mysql_fetch_array($q3)){
-
echo "addOption(document.form1.Specialization,'$nt3[SpecializationId]', '$nt3[SpecializationArea]');";
-
-
-
} // end of while loop
-
echo "}"; // end of JS if condition
-
-
}
-
?>
-
}
-
This is the insert statement from where the details go in database. -
mysql_query("INSERT INTO $db_table1(UserName,PhoneNo,MobileNo,YearsExp,MonthsExp,FunctionalArea,KeySkills,Qualification,Specialization,Institute,FunctionalRoles,CurrentEmployer,PreviousEmployers,ProfileTitle,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[PreviousEmployers]','$_POST[ProfileTitle]','$_POST[ResumeFile]')")
-
or die(mysql_error());
-
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|