Ajax allows updating server information without reloading the page. In this case, will be setting up a HTML select and display information specific to the selected option after ajax function is called when a select value is selected.
Three parts to this:
syntax for the HTML5 form:
<?php if($matchskill == false) {?>
<div class="alert alert-warning" role="alert">
<b>Warning</b> Unfortunately you do not have required SKILL Level to bid for this project
</div>
<?php } else {?>
Select your matching main skill:<br>
<select class="form-control" id='select' onchange='ajax("bidprocess.php", "input")'>
<option>Select Skill</option>
<?php
$levelRecord;
foreach($matchskills as $skill){
echo "<option ";
echo "value='";
echo $skill['Title'], ": ", $skill['member_has_skills_level'];
echo "' >";
echo $skill['Title'];
echo "</option>";
}
?>
</select>
<?php } ?>
syntax for the ajax script:
<script type="text/javascript">
function ajax(url,id) {
$.ajax({
type: "POST",
url: url,
data : {select:$('#select').find("option:selected").val()},
error: function(xhr,status,error){alert(error);},
success:function(data) {
document.getElementById( id ).innerHTML = data;
}
});
}
</script>
and lastly the syntax for php:
<?php
$select = $_POST['select'];
//echo $select;
list($Title, $Level) = explode(":", $select);
echo "You have selected the skill: ";
echo $Title;
echo "<br>";
//echo $Level;
if($Level == " Level 1") {
echo "You are at Level 1 of this skill. For Level 1, you are allowed to enter $";
echo $GLOBALS['LEVEL']['LEVEL1_LOWER_LIMIT'];
echo " - $";
echo $GLOBALS['LEVEL']['LEVEL1_UPPER_LIMIT'];
echo " dollars per hour only.";
} elseif($Level == " Level 2") {
echo "You are at Level 2 of this skill. For Level 2, you are allowed to enter $";
echo $GLOBALS['LEVEL']['LEVEL2_LOWER_LIMIT'];
echo " - $";
echo $GLOBALS['LEVEL']['LEVEL2_UPPER_LIMIT'];
echo " dollars per hour only.";
} elseif($Level == " Level 3") {
echo "You are at Level 3 of this skill. For Level 3, you are allowed to enter $";
echo $GLOBALS['LEVEL']['LEVEL3_LOWER_LIMIT'];
echo " - $";
echo $GLOBALS['LEVEL']['LEVEL3_UPPER_LIMIT'];
echo " dollars per hour only.";
}
?>