View Full Version : Maybe I'm looking for an OnChange thing??

09-03-2006, 07:39 AM
Forgive the newbie'ness of Javascript here..

I have a pull down menu created with just five options. Instead of redirecting them to a URL, I'm hoping to create it that when the user makes their choice, clicks the button, text will be displayed below, based on the option they chose. Is this even possible in Javascript? I've searched up and down the web, but I just can't find what I'm looking for. Any help would be appreciated. I'd like to keep all this confined to a single html page too. Even getting the text to appear in a hidden (then appearing) text box.

09-03-2006, 08:13 AM
What are you going to do with the text?

09-03-2006, 08:35 AM
What are you going to do with the text?

Just have it displayed. If user picks option 1, predefined text will show. If they pick option 2, other text will display.

I'm ultimately using this for a small help/explaination webpage. I could type out all help stuff and give the end-user a truck load of info to read and sift through. I figured the pull-down menu, pick your option, click the button, text pertaining to the choosen option displays - would make the page look better and much easier to read and get their info quickly.

09-03-2006, 10:45 AM
Like this?:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function showText(ind){
var d = document.getElementById('mytext').getElementsByTagName('div');
var i=0;
<select name="mysel" onchange="showText(this.selectedIndex)">
<option>-- select --</option>
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<div id="mytext">
<div style="display:none"></div>
<div style="display:none">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur mauris nulla, tempus eget, scelerisque a, vulputate vitae, ante. Maecenas malesuada diam eu ligula. In sit amet turpis. Sed quam nisi, elementum at, porttitor sit amet, ullamcorper aliquam, risus. Aenean ante diam, varius ut, semper eu, aliquam id, lacus. Donec fermentum. Curabitur condimentum condimentum libero. Proin vel massa. Nunc erat. Morbi aliquet nunc id metus. Morbi malesuada metus a leo. Praesent lacinia aliquet arcu. Pellentesque quis augue. Fusce cursus pellentesque nisl. Ut lorem.
<div style="display:none">
Nunc facilisis malesuada augue. Sed sapien. Vestibulum suscipit. Vivamus suscipit. Sed nulla. In hac habitasse platea dictumst. Curabitur felis tortor, cursus eu, congue in, vehicula a, nisi. Morbi auctor iaculis tellus. Aenean tristique egestas augue. Etiam laoreet ullamcorper dolor. In congue nunc ac felis. Aliquam suscipit.
<div style="display:none">
Nam cursus consequat tortor. Donec vel lectus et lacus eleifend egestas. Proin pellentesque lacinia purus. Etiam mattis interdum turpis. Nulla facilisi. Sed blandit arcu nec nunc. Phasellus mattis iaculis ligula. Vivamus consequat neque in sem. Donec erat tortor, rutrum ut, ultricies quis, auctor ut, leo. Curabitur volutpat.

09-03-2006, 06:53 PM
Kor - This is EXACTLY what I'm looking for! You're awesome...Thank you very much!