hi,
I am creating a script where i have 4 combo box collecting the value from database. and i want if some one select the other option from the combo box the text box is enable.
and all 4 combo box have an alternative text box and i want same feature.
when page is load 1st time by default all the text box should
disable.
and as we select the other option from combo boxes the page reload
with appropriate enabled text box.
the problem is when i select any option other then 'others'
it works fine but when i select 'other' option instead of open the text box it still disable.
I cant understand the problem....
thats my code of javascript:
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='create_own_inventory.php?cat=' + val ;
}
function def()
{
document.f1.newcat.disabled=true;
document.f1.newsubcat1.disabled=true;
document.f1.newsubcat2.disabled=true;
document.f1.newsubcat3.disabled=true;
}
function makeChoice()
{
var val = 0;
document.f1.newcat.disabled=true;
document.f1.newsubcat1.disabled=true;
document.f1.newsubcat2.disabled=true;
document.f1.newsubcat3.disabled=true;
for( i = 0; i < document.f1.cat.length; i++ )
{
if( document.f1.cat.options[i].selected == true )
{
val = document.f1.cat.options[i].value;
if(val=='other')
{
document.f1.newcat.disabled=false;
document.f1.newcat.focus();
}
}
}
}
my php combo box is:
echo " <select name='cat' onchange=\"reload(this.form)\" onclick=\"makeChoice()\"><option value=''>Main Catagory</option>";
while($noticia2 = mysql_fetch_array($quer2))
{
if($noticia2['Top_Level_Category']==@$cat)
{
echo "<option selected value='$noticia2[Top_Level_Category]'>$noticia2[Top_Level_Category]</option>"."<BR>";
}
else
{
echo "<option value='$noticia2[Top_Level_Category]'>$noticia2[Top_Level_Category]</option>";
}
}
echo "<option value='other'>Others</option>";
echo "</select> OR Create Own Main Catagory";
echo '<INPUT TYPE="text" NAME="newcat"><BR><BR>';
function def() i am using in body onload
event using
<body onload="def();">
plz help me what is my problem???
in that code in javascript