|
-
form menu and set text in a div
Hi
I have an html mail form and i'm using menu to select the mail to which it shall be sent. But I wanna know if is it possible to have a set text function performed when an item in a form menu is selected, cause I want too to change the content inside a div in the page when items are selected.I'm not quiet sure how this can be done -.-.
I'm working with the javascripts "bundled" inside dreamweaver cs3 =).
thanks in forward
-
If I understand you correctly, all you need is to put the JavaScript onChange event handler in the SELECT's tag, kinda like this:
<select name="input" onchange="return SOME_JS_FUNCTION(this.value);">
<option value="1">1</option>
<option value="2">2</option>
</select>"
Then in the JS function you would change the innerHTML of the div in question.
-
Seems you almost got me =)
In your sugestion, no matter wich option is select, the change on div is always the same.
I think my code for that is this:
Code:
<select name="email" id="email" tabindex="1" onchange="MM_setTextOfLayer('abc','','ssss')">
<option value="aaa">aaa</option>
<option value="bbb">bbb</option>
</select>
But i need a diferent set text for each option, so i tried this:
Code:
<select name="email" id="email" tabindex="1">
<option value="aaa" onclick="MM_setTextOfLayer('abc','','aaa')">aaa</option>
<option value="bbb" onclick="MM_setTextOfLayer('abc','','bbb')">bbb</option>
</select>
but this seems to work only in firefox and safari -.-, no opera/ie. I want something like that but working in ie. Any tip ^^
-
well i'm whiling to learn how to do this so i'll take also sugestions for other methods, seems so far i think this i've been trying won't work out.
thanks in advance again =)
-
But i need a diferent set text for each option, so i tried this:
Code:
<select name="email" id="email" tabindex="1">
<option value="aaa" onclick="MM_setTextOfLayer('abc','','aaa')">aaa</option>
<option value="bbb" onclick="MM_setTextOfLayer('abc','','bbb')">bbb</option>
</select>
but this seems to work only in firefox and safari -.-, no opera/ie. I want something like that but working in ie. Any tip ^^
onclick isn't a valid handler for the option tag. It works in FF & Safari because they are extra flexible and IE/Opera aren't.
The following code (a full version of what I provided before) works just fine in FF, IE & Chrome:
Code:
<html>
<head>
<script type="text/javascript">
function swapped(inVar){
document.getElementById('changer').innerHTML = inVar;
}
</script>
</head>
<body>
<div id="changer">Default Text</div>
<select name="input" onchange="return swapped(this.value);">
<option></option>
<option value="[email protected]">Email Me</option>
<option value="[email protected]">Email Him</option>
</select>
</body>
</html>
If you want to place more advanced text in the div you'll need to add more processing to the JS function.
-SDPETERSEN
Mohican Web Ware
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|