Jump to content


Photo

Select-field + Javascript


  • Please log in to reply
1 reply to this topic

#1 aeris130

aeris130
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 29 April 2006 - 12:58 PM

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

<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>

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

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


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.

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

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?





#2 GBS

GBS
  • Members
  • PipPipPip
  • Advanced Member
  • 108 posts

Posted 29 April 2006 - 03:05 PM

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,

Sorry for my english,... I do my best, but sometimes,...
1st intention: understand the problem
2nd intention: try to solve it
3rd intention: try to understand how to solve it :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users