Now we create the insert form. As we can see, in the RE_Prov select I have put an attribute that we will use to modify it. If it is empty when inserting, nothing happens.
echo “
“;
?>
This is the Script that we will use to search the database.
Script details:
To know the value of the province: var number =document.getElementById(“province”).value;
When we move this select we write in search…. this is put here:
var to=document.getElementById(“Searching”);
to.innerHTML=”looking for….”;
We send the desired information to the document busqueda.php in post and send this data:
data: ‘idnumber=’+number+’&idpopula=”+population,
idnumber is the value of the province select and idpopula is the attribute but now it is empty.
When the search is done we will show it here:
jQuery(“#populationList’).html(a);
and we will delete it looking for… like this:
var to=document.getElementById(“Searching”);
to.innerHTML=””;
We put the insertion to the database.
if($_POST){
$name=addslashes($_POST);
$RE_Prov=addslashes($_POST);
$RE_popula=addslashes($_POST);
$insertar=mysql_query(“INSERT clients (name,province,population) VALUES (‘$name’,’$RE_Prov’,’$RE_popula’)”,$link);
if ($insert==1){echo ““;}else{echo ““;}
}
?>
and we close: