Today is . Page created 05/24/07
Drop Down Info Box |
|
This script reveals information, based on the user's selection in a drop down box. Can be used for a FAQ, contact info, and more. Short and sweet, with comments. We have tested the code in IE 7.0, Firefox 2.0.0.3, Opera 9.21, Netscape 8.1.3 and AOL Explorer 1.5. This script worked well in all platforms with no variations observed. |
Depending on your knowledge of HTML and javascripts, this is an easy four (4) part copy and paste code that goes in both the <HEAD> (2 parts-CSS Section and external.js file) and <BODY> section (wherever you want it to appear) of your document. The external .js file you will need to save and upload into your directory (which by the way does not have any reconfigurations) then add a snipplet of code into the <HEAD> section to call the external.js file.
Let us start with the CSS section of code. This is for all intensive purposes the cosmetic appearance of each option that will appear upon selection of the drop down menu. Unlike most CSS codes, this one has the capability to make each selection different instead of the usual appearance of all looking the same. As you can see in our above example, each option appears different (cosmetically). See below where and howto reconfigure this section.
<style type="text/css"> |
All of the color coded sections on the left can be reconfigured to your specifications. Just play around with them until it works for you. Notice each section is a total entity in itself ; #form1, #form2 etc. This is why each section can be configured totally different and apart from any other.
|
For your Information: In regards to the above CSS section, if you need to add more than the default number of three (3) options, just follow the above format and do not forget to go up with the numbers chronologically or the effect will not work correctly.
The last thing we will cover with the CSS section is the way you add this into your document.
The script site tells you to......
"......Paste this code into your external CSS file or in the <style> section within the <HEAD> section of your HTML document......"
<style type="text/css"> CSS Section Of Code Goes Here </style> |
<!---------- Opening CSS Style Tag <!---------- Closing CSS Style Tag |
Afer the above in done, now you will need to make another section of code into an external.js file. Same procedure as with the external.css file just with this it will have the file extension of .js attached and once "Saved As" it will look something like this. The next part we shall cover is the <BODY> section (both parts) of code. This is copied and pasted anywhere you want the effect to be visible. First <BODY> Section - Drop Down Menu - <form name="selector"> Second <BODY> Section - What Appears Upon Selection <div id="allForms">
For your Information: If you notice in the above both parts that the color coded sections are correlated to each other. Number 1 relates to number 1, number 2 relates to number 2 etc. This also holds true for the CSS part in the <HEAD> section of code. In other words, all three (3) parts must be in sync with each other.
Note Of Importance: On the page you are going to have this effect on or any page that will link to the page with this effect, be sure of one thing within either the linking URL or the URL this effect is on. Do Not have the backslash-forward slash / (whichever you call it) at the end of the URL or linked to URL. If you do, the effect Will Not Work!. If this sounds confusing, see the below example:
S
elect the links above to see what we are explaining about the Right and Wrong URL address.
If you notice in our example nothing moves below this effect to make room for the material that appears upon selection. Reason being is quite simple. We added a table around the <BODY> section of code. Since we have material to the right of the effect that takes up the slack, we did not need to add a height attribute into the table. Just add a table such as the below around the effect and play around with the height attribute until you do not get any movement below the largest option that appears. See below howto add the table. We hope our tutorial was easy to follow and we covered everything in detail. If you would like to add this effect into your pages, grab the respective below link and you are there. If you have any problems with this or anything else, feel free to consult our [ FAQ ] and if you can't find the answer there, [ contact us ].
Once uploaded now paste the below snipplet of code into the <HEAD> section to call the external.js file.
<script type="text/javascript" src="dropDownInfoBox.js">
</script>
<select id="someID" name="someID" onChange="selectForm(this.options[this.selectedIndex].value)">
<option> Select a Question </option>
<option value="1"> Selection 1 Here</option>
<option value="2"> Selection 2 Here</option>
<option value="3"> Selection 3 Here</option>
</select>
</form>
<form id="form1">
Information For Selection 1 Here.
</form>
<form id="form2">
Information For Selection 2 Here.
</form>
<form id="form3">
Information For Selection 3 Here.
</form>
</div>
<table border="1"cellpadding="4"
cellspacing="3">
<tr>
<td valign="top" align="left" height="?">
<BODY> section of code here
</td><tr>
</table>
Just substitute the height value for the ?, align the effect inside the table either left, right or center and either have a border (1 or higher) or use a zero 0 for no border.
[ Get Code Here ]
[ Rate This Page ]