PDA

View Full Version : Is this possible ??????


elbob2492
04-20-2003, 05:34 PM
looking for a script that .....when a selected item menu is chosen, the word in a schedule or table on that same page will be highlighted wherever present. These are baseball schedules with multiple listings of games. It would allow the viewer to find their games among other listings.

HairyTeeth
04-20-2003, 10:12 PM
Something like this perhaps?


<html>
<head>

<title>Demo</title>

<script type="text/javascript" language="javascript">
<!--;

/*
*
* init()
* Makes sure the select form is hidden
* from older browsers but that it is visible
* to browser that understand
* document.getElementsByTagName
*
*/

function init(){
var theDiv;

if(document.getElementById){
theDiv = document.getElementById('teamForm');
theDiv.style.visibility = "visible";
}else if(document.all && ! document.getElementById){
theDiv = document.all.teamForm;
theDiv.style.visibility="hidden" ;
}else if(document.layers){
theDiv = document.teamForm ;
theDiv.visibility = "hidden";
}
}

//Find and highligh the selected team;
function findTeam(f){
var selectedTeam = f.selTeam;
var teamName = selectedTeam.options[selectedTeam.selectedIndex].value;
var theTeam;

//styles for selected team;
//Change to suit;
var highlightColor = "#FFFFFF"
var highlightBackground = "firebrick"
var highlightFontWeight = "bold"

//Styles for de-selected team;
//Change to suit;
var defaultColor = "#000000" //black;
var defaultBackground = "#FFFFFF"//white;
var defaultFontWeight ="normal";

if(document.getElementsByTagName){
theTeam=document.getElementsByTagName('td');
if(document.getElementById('teamTable'){
for(i=0;i<theTeam.length;i++){
if(theTeam[i].innerHTML == teamName){
theTeam[i].style.fontWeight = highlightFontWeight;
theTeam[i].style.color = highlightColor;
theTeam[i].style.backgroundColor = highlightBackground;
}
//if not the selected team, change to the usual style;
if(theTeam[i].innerHTML != teamName){
theTeam[i].style.fontWeight = defaultFontWeight;
theTeam[i].style.color= defaultColor;
theTeam[i].style.backgroundColor = defaultBackground;
}
}
}
}
}

//-->
</script>

</head>

<body onload="init()">

<div id="teamForm" style="visbility:hidden;position:relative">
<form>
<select name="selTeam" onchange="findTeam(this.form)">
<option value=''>Select a team...</option>
<option value="Wallaby's">Wallaby's</option>
<option value="Springboks">Springboks</option>
<option value="The Blues">The Blues</option>
<option value="Redbacks">Redbacks</option>
<option value="All Blacks">All Blacks</option>
<option value="Ted's Thumpers">Ted's Thumpers</option>
<option value="Moo Cows">Moo Cows</option>
</select>
<input type="button" value="Find" onclick="findTeam(this.form)">
</form>
</div>

<table width="600" border="1" id="teamTable">
<tr>
<th>Home Team</th>
<th>Away Team</th>
<th>Venue</th>
<th>Date</th>
</tr>

<tr>
<td>Wallaby's</td>
<td> Springboks</td>
<td>Ballymore</td>
<td>June, 5, 2003</td>
</tr>

<tr>
<td>All Blacks</td>
<td>Moo Cows</td>
<td>Anzac Stadium</td>
<td>May, 15, 2003</td>
</tr>
<tr>
<td>Springboks</td>
<td>Ted's Thumpers</td>
<td>Outside a Bush Pub</td>
<td>August, 21, 2003</td>
</tr>

<tr>
<td>Redbacks</td>
<td>The Blues</td>
<td>M.C.G</td>
<td>August, 21, 2003</td>
</tr>

<tr>
<td>Moo Cows</td>
<td>Springboks</td>
<td>M.C.G</td>
<td>August, 21, 2003</td>
</tr>


<tr>
<td>Wallaby's</td>
<td> Springboks</td>
<td>Ballymore</td>
<td>June, 5, 2003</td>
</tr>

<tr>
<td>All Blacks</td>
<td>Moo Cows</td>
<td>Anzac Stadium</td>
<td>May, 15, 2003</td>
</tr>

<tr>
<td>Springboks</td>
<td>Ted's Thumpers</td>
<td>Outside a Bush Pub</td>
<td>August, 21, 2003</td>
</tr>

<tr>
<td>Redbacks</td>
<td>The Blues</td>
<td>M.C.G</td>
<td>August, 21, 2003</td>
</tr>

<tr>
<td>Moo Cows</td>
<td>Springboks</td>
<td>M.C.G</td>
<td>August, 21, 2003</td>
</tr>
</table>

</body>
</html>

elbob2492
04-21-2003, 03:40 AM
The principle is exactly what I was looking for....however the code does not work for me in HTML and shows an error....
elbob2492

duniyadnd
04-21-2003, 03:50 AM
I have it on my home page, so I just cut and pasted. Not sure if this exactly what you wanted, but it should work.


<form action="" class="thin" name="searchIt" onSubmit="frmval=false;nswin=self;iewin=self;if((this.search.value!=null) && (this.search.value!=''))findString(this.search.value);return false">
<input type="text" name="search" class="textfielda" size="20" />
<input type="submit" name="searchit" value="Search" class="button" />
</form>



*Note, it isn't a drop down menu though.

Duniyadnd

HairyTeeth
04-21-2003, 04:13 AM
I see. I thought you were making your own table. No prob.