Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP with Javascript Question on Hiding DropList

Status
Not open for further replies.

cranger01

IS-IT--Management
Oct 2, 2006
34
US
What I need to do is when I go to a page, there are 2 drop downs. Want to hide the second drop down until they make a selection. Then rehide it if they want to start from the beginning again. I found the command to hide initially. I am thinking that during the onchange I can call a function to set the hide property....but I am not that good with Javascript, so not sure what I should be passing and setting. Also, not sure if I need or can do 2 onchange requests or if I can do it in the one I am currently calling. Any help?

In the one .php here is the code with the non variable Hide command. Subcat is what is hidden.

<FORM name="drop_list" action="game-detail.php" method="POST" >

<SELECT id="Category" NAME="Category" onChange="SelectSubCat();" >
<Option value="">Category</option>
</SELECT>&nbsp;
<SELECT id="SubCat"onChange="SelectSubCat2();" NAME="SubCat" style="visibility=hidden;">
<option value="" selected>SubCat</option>
</SELECT>
<br><br>
<select id="Themes" onchange=SelectSubCat();SelectSubCat2();" onclick="this.form.submit();" name="Themes" size="5">
<option value="" selected>Themes</option>
&nbsp;&nbsp;
<br><br>

<input type="reset" name="Reset" OnClick="ResetAll();" value="New Search">

when the onchange=selectsubcat is active, I call this code in another page. This is where I need to set to unhide.



function SelectSubCat(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat);
addOption(document.drop_list.SubCat, "", "SubCat", "");

removeAllOptions(document.drop_list.Themes);

<?php

foreach ($tblThemeGroupArray as $tblThemeGroupTypeInfo){

echo "if(document.drop_list.Category.value == \"".$tblThemeGroupTypeInfo[0]."\"){\n";

$themeInfo=mysql_query("SELECT ThemeRecordId, ThemeName, ThemeMark FROM tblThemes
Where Active=\"Yes\" and ThemeGroupTypeID= ". $tblThemeGroupTypeInfo[0]." ORDER BY ThemeName", $linkID3);

$LicenceInfo=mysql_query("SELECT DISTINCT tblLicense.`LicenseID`, tblLicense.LicenseDescription
FROM `tblLicense` Inner join tblThemes on tblLicense.LicenseID=tblThemes.LicenseID
where tblThemes.Active=\"Yes\" and ThemeGroupTypeID= ". $tblThemeGroupTypeInfo[0]. " ORDER BY tblLicense.LicenseDescription" , $linkID4);


// ** Put The Category License and Theme Information info in an array
$LicenceInfoArray=Array();
$counter=0;
//$rrows = mysql_num_rows($LicenceInfo);

//while($row = mysql_fetch_row($LicenceInfo)){
// array_push($LicenceInfoArray, $row);
//}



$inside_counter=1;

while($Licence = mysql_fetch_row($LicenceInfo)){

// array_push($LicenceInfoArray, $Licence);

echo "addOption(document.drop_list.SubCat,\"".$Licence[0]."\", \"".$Licence[1]."\");\n";
//echo "addOption(document.drop_list.Themes,\"".$theme[0]."\", \"".$theme[1]."\");\n";

}

while($theme= mysql_fetch_row($themeInfo)){

//echo "addOption(document.drop_list.SubCat,\"".$Licence[0]."\", \"".$Licence[1]."\");\n";
echo "addOption(document.drop_list.Themes,\"".$theme[0]."\", \"".$theme[1]."\");\n";

}


echo "}\n";

}
echo "}\n";
 
Oh,

In the selectsubcat function I just tried to put in a line for testing sake that said the below, but I got an error for expected "=".

document.drop_list.SubCat.sytle.visiblity = "hidden";
 
Never Mind...I got it. Just had it in the wrong place.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top