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 "&nbsp;&nbsp;&nbsp;<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>&nbsp;&nbsp; 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

Could you post the HTML from a View Source on your browser? I can't see what your select options look like from the server code.

Could you post the HTML from a View Source on your browser? I can't see what your select options look like from the server code.

I send my code with database structure.
2 files r php file and data1.txt is database file.
plz create your own connection string of php mysql
plz help me.

I send my code with database structure.
2 files r php file and data1.txt is database file.
plz create your own connection string of php mysql
plz help me.

Hi frnd i am waiting for your reply and already sent my file and database structure.

in the current php file i dont use none of the javascript which i was mentioned above.plz give me the way and procedure to use those one or any other to achieve my goal...
thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.