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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown Div Content 1

Status
Not open for further replies.

bam720

Technical User
Sep 29, 2005
289
US
I tried a quick search and didn't find anything. I'm also new to javascripting (more of an html/css guy). I have a drop down list of about 10 cities. When a user selects a city I'd like for a div under this dropdown box to be populated with a different paragraph/phone number. The paragraph for each city is unique, but static (not database driven). I was thinking of using a function with the onchange event to set this paragraph text, then use maybe a conditional if statement to display the text in the div. Any help would be greatly appreciated. Thanks in advance.

Here is what I have so far:

Code:
<SCRIPT LANGUAGE=javascript>
function OnChange(loc)
{
 alert ("Yay!")
    var myindex  = loc.selectedIndex
    var SelValue = loc.options[myindex].value
    var baseURL  = "google.com"
    
    document.getElementById('pictitle').innerHTML=baseURL;
    return true;
}
</SCRIPT>

<select name="loc" onchange='OnChange(this.form.loc);'>
obviously my borrowed code isn't all the way there.
 
Try using this:

Code:
<select name="loc" onchange="OnChange(this.value);">

and this:

Code:
<script type="text/javascript">
function OnChange(loc) {
	var baseURL  = 'google.com';
	document.getElementById('pictitle').innerHTML = loc + ' ' + baseURL;
}
</script>

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thank you for the help. A Star to you...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top