Jump to content

Archived

This topic is now archived and is closed to further replies.

aeris130

Select-field + Javascript

Recommended Posts

I have the following script written in my head-section:

[code]<script>
function showhide(id){
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == "none"){
obj.style.display = "";
} else {
obj.style.display = "none";
}
}
}
</script> [/code]

Then I use the following link to show/hide divs (and their content):

[code]<a href="#" onclick="showhide('div_venice'); return(false);">Venice</a>[/code]


The problem is, I want to put these links on a select-list, and assign different values (for a php query) when I select them.

[code]<select name="a_serie">
  <option value ="none">       </a></option>
  <option value ="ven">Venice</a></option>
  <option value ="yor">York</a></option>
  </select>[/code]

When i select one of the two cities, I also want the javascript-link to show/hide its div. Are there any solutions for this?



Share this post


Link to post
Share on other sites
Hi there,,

I guess you should use the 'onselect' property with select objects,,

try something like:
----
<option value ="ven" onselect=showhide('div_venice')>Venice</option>
----
& the value "ven" could be used in the php part,

hmm,,... & I don't think you need to use the '<a href="#" ...>' in what you need,... some onmouseover/onmouseout could do the thing,

Hoping it helps,,

l8tr,

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.