Jump to content

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?



Link to comment
https://forums.phpfreaks.com/topic/8701-select-field-javascript/
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,
Link to comment
https://forums.phpfreaks.com/topic/8701-select-field-javascript/#findComment-31962
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.