I am trying to create a form for job applications on my website using PHP that allows selecting options from multiple drop down lists allows me to access multiple data but it doesn't allow me
Here's the code below for the form that demonstrates the issue (I have deleted all the other junk):
<?php
/*
*session start;
* dis is a session array;
* i is a session variable;
*/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body
{
background-image:url('banner.jpg');
background-repeat:no-repeat;
background-position: center center;
}
</style>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1' />
<link rel='stylesheet' type='text/css' href='styles.css' />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function f()
{
var specifications=document.getElementById('specifications').value;
var category=document.getElementById('category').value;
var country=document.getElementById('country').value;
var countryareacode=document.getElementById('countryareacode').value;
document.getElementById('upd').href+='&specifications='+specifications+'&category='+category+'&country='+country+'&countryareacode='+countryareacode;
}
function SelectAccountHead_Code(i)
{
var k=document.getElementById("menu").selectedIndex;
var l=document.getElementById("menu1").selectedIndex;
if((k>0)&&(l>0))
{
self.location="jobinterviews.php?id="+document.getElementById("menu").options[k].value+"&id2="+document.getElementById("menu").options[k].innerHTML +"&id3="+document.getElementById("menu1").options[l].value+"&id3="+document.getElementById("menu1").options[l].innerHTML;
}
}
function SelectAccountHead_Codes(j)
{
var k=document.getElementById("menu").selectedIndex;
var l=document.getElementById("menu1").selectedIndex;
if((k>0)&&(l>0))
{
self.location="jobinterviews.php?id="+document.getElementById("menu").options[k].value+"&id2="+document.getElementById("menu").options[k].innerHTML +"&id3="+document.getElementById("menu1").options[l].value+"&id3="+document.getElementById("menu1").options[l].innerHTML;
}
}
function SelectUp(i)
{
var k=document.getElementById("menuUp").selectedIndex;
var l=document.getElementById("menuUp").selectedIndex;
self.location="jobinterviews.php?id="+document.getElementById("menuUp").options[k].value+"&id2="+document.getElementById("menu").options[k].innerHTML +"&id3="+document.getElementById("menu1").options[l].value+"&id3="+document.getElementById("menu1").options[l].innerHTML;
}
function SelectUp(j)
{
var k=document.getElementById("menuUp").selectedIndex;
var l=document.getElementById("menuUp").selectedIndex;
self.location="jobinterviews.php?id="+document.getElementById("menuUp").options[k].value+"&id2="+document.getElementById("menu").options[k].innerHTML +"&id3="+document.getElementById("menu1").options[l].value+"&id3="+document.getElementById("menu1").options[l].innerHTML;
}
}
</script>
</head>
<br><br><br><br><br>
<H2 align="center"><u>JOB APPLICATION FORM </u></H2>
<form id="myform" action="" align="center" method="post" enctype="multipart/form-data">
<div id="div2">
<table border="1" cellspacing="0" style="margin-top:12px width="900"">
<colgroup>
<col span="1">
</colgroup>
<?php
$_SESSION["specifications"]="";
$_SESSION["category"]="";
$_SESSION["country"]="";
$_SESSION["countryareacode"]="";
if(!isset($_GET["id2"]))
{
$_GET["id2"]="";
}
else
{
$z=$_GET["id2"];
$sql2 = "SELECT * from specifications where specifications='$z'";
$smt2 = $dbs->prepare($sql2);
$smt2 -> execute();
while($row2 = $smt2->fetch(PDO::FETCH_ASSOC))
{
$_SESSION["category"]=$row2["category"];
$_SESSION["specifications"]=$row2["specifications"];
}
}
if(!isset($_GET["id3"]))
{
$_GET["id3"]="";
}
else
{
$p=$_GET["id3"];
$sql2 = "SELECT * from countryareacode where country='$p'";
$smt2 = $dbs->prepare($sql2);
$smt2 -> execute();
//$result=mysqli_query($con,"SELECT * from brand where brands='$p'");
while($row2 = $smt2->fetch(PDO::FETCH_ASSOC))
{
$_SESSION["country"]=$row2["country"];
$_SESSION["countryareacode"]=$row2["countryareacode"];
}
}
?>
<tr>
<td valign="top">
<input type="text" name="last_name" maxlength="30" size="38">
</td>
</tr>
</table>
<p>
<table border="1" cellspacing="0" style="margin-top:12px width="900"">
<colgroup>
<col span="1">
</colgroup>
<tr>
<td valign="top">
<label for="address">Current Address: </label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="50" size="150">
</td>
</tr>
</table>
<p>
<table border="1" cellspacing="0" style="margin-top:12px width="900"">
<colgroup>
<col span="1">
</colgroup>
<tr>
<td valign="top">
<label for="address">Line 2: </label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="50" size="160">
</td>
</tr>
</table>
<p>
<table border="1" cellspacing="0" style="margin-top:12px width="900"">
<colgroup>
<col span="1">
</colgroup>
<tr>
<td valign="top">
<label for="email">Email Address: </label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>
</form>
<td valign="top">
<label for="country">Country: </label>
</td>
<td>
<select name="country" id="menu1" onChange="SelectAccountHead_Codes(this.value)">
<option value="<?php if(isset($_POST['country'])) { echo $_POST['country']; } ?>">Select Country</option>
<?php
$sql2a = "SELECT * FROM countryareacode";
$smt2a = $dbs->prepare($sql2a);
$smt2a -> execute();
while($row2a=$smt2a->fetch(PDO::FETCH_ASSOC))
{
if($row2a['country']==$_GET['id3'] )
echo ("<option selected value=$row2a[country]>$row2a[country]</option>");
else
echo ("<option value=$row2a[country]>$row2a[country]</option>");
}
?>
</select>
</td>
<td valign="top">
<label for="phone">Landline Number: </label>
<input readonly type="text" id="countryareacode" value='<?php echo $_SESSION["countryareacode"]; ?>' name="countryareacode" maxlength="3" size="3"/> -
<input type="text" name="phone" maxlength="25" size="12">
</td>
<td valign="top">
<label for="cellphone">Mobile Number: </label>
<input type="text" name="cellphone" maxlength="25" size="3"> <input type="text" name="cellphone" maxlength="25" size="15">
</td>
</tr>
</table>
<p>
<table border="1" cellspacing="0" style="margin-top:12px width="900"">
<colgroup>
<col span="1">
</colgroup>
<tr>
<td valign="top">
<label for="specifications">Specification: </label>
</td>
<td valign="top">
<select name="specifications" id="menu" onChange="SelectAccountHead_Code(this.value)">
<option value="<?php if(isset($_POST['specifications'])) { echo $_POST['specifications']; } ?>">Select Specification</option>
<?php
$sql1a = "SELECT * FROM specifications ORDER BY specifications asc";
$smt1a = $dbs->prepare($sql1a);
$smt1a -> execute();
while($row1a=$smt1a->fetch(PDO::FETCH_ASSOC))
{
if($row1a['specifications']==$_GET['id2'] )
echo ("<option selected value=$row1a[specifications]>$row1a[specifications]</option>");
else
echo ("<option value=$row1a[specifications]>$row1a[specifications]</option>");
}
?>
</select>
<td valign="top">
<label for="category">Category: </label>
</td>
<td valign="top">
<input readonly type="text" id="category" value='<?php echo $_SESSION["category"]; ?>' name="countryareacode" maxlength="20" size="20"/>
</td>
<td valign="top">
<label for="position">Position: </label>
<input readonly type="text" id="" name="position" maxlength="20" size="20"/>
</td>
<td valign="top">
<label for="additionalinfo">Additional Information: </label>
</td>
<td valign="top">
<textarea name="additionalinfo" maxlength="1000" cols="23" rows="1"></textarea>
</td>
</tr>
<br><br>
</table>
</div>
<br><br>
<tr>
<table border="1" cellspacing="0" style="margin-top:12px width="900"">
<colgroup>
<col span="1">
</colgroup>
<td>
<label for="file">Resume:</label>
<input type="file" name="files[]" multiple="multiple" accept="application/*">
</td>
<td> <input type="submit" name ="submits" value="Upload">
</td>
<td>
<label for="file">Portfolio (Previous Work):</label>
<input type="file" name="files1[]" multiple="multiple" accept="application/*">
</td>
<td>
<button type="submit" name="submitd" value="Save"/>Save</button></td></tr>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
When I tried to add an event to the other data inputs, they are not working. They only work for drop down lists. So the extension of the PHP file ends up printing out the elements of the drop down list - jobinterviews.php?id=jjkuu&id2=jjkuu&id3=Canada&id3=Canada
how can i extend the extension via Java script/AJAX - etc &ud4=Jose&id4=Jose ..if I enter "Jose" in the input bar for the first name? If i start filling out he tforms without selecting from the drop down list, the other inputs for data will clear and restart...how can I get the data from the input to show up along with the options selected at the same time?
I have deleted all the extra code and just left the relevant Javascript code and the code for the entire form - please help out.