hello guys im new here so please be kind with me, please be patience cause Im new in PHP.
now here's my problem I really miss-up my code. I want to create a form with 4 dropdownlist (diagnosis, cause, medicine, and treatment) this drop-downs are dynamic taking there items from my database... cause, medicine, and treatment items are dependent on diagnosis value..
and in diagnosis there is a static item which is other with a value of other. now I want a textbox to appear every time other is selected in my diagnosis dropdown....
//by: lifeworks
<SCRIPT language=JavaScript>
window.onload = initForm;
function initForm(){
document.getElementById('selectedDiag').selectedIndex = 0;
document.getElementById('selectedDiag').onchange = showHideBox;
}
function showHideBox(){
var whichForm = document.getElementById('selectedDiag');
var theForm = whichForm.options[whichForm.selectedIndex].value;
if(whichForm.options[whichForm.selectedIndex].value == 'other'){
document.getElementById('selectedOther').style.display='';
}
else{
document.getElementById('selectedOther').style.display='none';
}
}
</script>
this is for the textbox to appear...
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.selectedDiag.options[form.selectedDiag.options.selectedIndex].value;
self.location='updateMedicalRecords.php?selectedDiag=' + val ;
}
</script>
this code does not functional since I put function showHideBox()
echo "<form id=f1 method=post name=f1 action=''>";
echo "<select id='selectedDiag' name='selectedDiag' onchange=\"reload(this.form) && showHideBox()\"><option value=''>Select diagnosis</option>"."<option value='other'>other</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['diagnosisId']==@$diag){echo "<option selected value='$noticia2[diagnosisId]'>$noticia2[diagnosisName]</option>"." "."<BR>";}
else {
echo "<option value=$noticia2[diagnosisId]>$noticia2[diagnosisName]</option>";
}
}
echo "</select>";
////////// Starting of second drop downlist /////////
echo "<select name='cause'>
<option value=''>Select cause</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[causeId]'>$noticia[cause]</option>";
}
echo "</select>";
////////// Starting of third drop downlist /////////
echo "<select name='medicine'>
<option value=''>Select medicine</option>";
while($noticiamed = mysql_fetch_array($mediquery)) {
echo "<option value='$noticiamed[medicineId]'>$noticiamed[medicineName]</option>";
}
echo "</select>";
echo "<input type=submit value=Submit>";
echo "</form>";
and also the third dropdown has no item appearing, I dont know if its in my PHP code of in query..
<input name='txt' type='text' id='selectedOther' style='display:none' />
please help me guys.. and more power