...

View Full Version : Forms x 2 - How Do I do It??



iluka
07-07-2003, 01:41 PM
Hi, I am a real self taught beginner at Javascript and want to put two FORMS on the one page. I have tried to use the FAQ pages but as I really dont know what I am doing still cant make them work.
I used the --- Drop down menu w/ description All NS6! for the form and got that to work OK.
BUT when I try to put a second FORM on the same page..!!!!
I understand that I have to insert extra SCRIPT but dont know what or just where this has to go...........
The page address is
http://www.geocities.com/iluka_aust/indexjuly.html

Hope someone can tell me how to do this in EASY TO UNDERSTAND language.
Thanks for any help. iLuka:confused:

tata
07-07-2003, 02:23 PM
Hi! I was just asking the same question today and I got an answer from somewhere else. There is a code below that makes two drop down boxes. See in the first part of the code ("function contractall2...") that's where the code necessary for making the 2nd box starts. Then see the end of the code there form 2 starts. That's how yo do it. Then just continue woth 3 and 4 and 5 etc...

Print the code out to see it better. I have no time for shortening it. Sorry about that!


<style type="text/css">
.dropcontent{
width: 300px;
height: 140px;
border: 1px solid black;
background-color: #FFECC6;
display:block;
}
</style>

<script type="text/javascript">
<!--
/*
Combo-Box Viewer script- Created by and Dynamicdrive.com
Visit http://www.dynamicdrive.com/ for this script and more
This notice MUST stay intact for legal use
*/

if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.dropcontent{display:none;}\n')
document.write('</style>\n')
}

function contractall(){
if (document.getElementById){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}
}

function expandone(){
if (document.getElementById){
var selectedItem=document.dropmsgform.dropmsgoption.selectedIndex
contractall()
document.getElementById("dropmsg"+selectedItem).style.display="block"
}
}

function contractall2(){
if (document.getElementById){
var inc=0
while (document.getElementById("drop2msg"+inc)){
document.getElementById("drop2msg"+inc).style.display="none"
inc++
}
}
}

function expandone2(){
if (document.getElementById){
var selectedItem=document.dropmsgform2.dropmsgoption.selectedIndex
contractall2()
document.getElementById("drop2msg"+selectedItem).style.display="block"
}
}


if (window.addEventListener)
window.addEventListener("load", expandone, false)
else if (window.attachEvent)
window.attachEvent("onload", expandone)

// -->
</script>


<form name="dropmsgform">
<select name="dropmsgoption" size="1" style="width:300" onChange="expandone()">
<option selected>What is JavaScript?</option>
<option>Difference betwen Java and JavaScript</option>
<option>What is DHTML?</option>
</select>
<br>

<div id="dropmsg0" class="dropcontent">
JavaScript is a scripting language originally developed by Netscape to add interactivity and power to web documents. It is purely client side, and runs completely on the client's browser and computer.
</div>

<div id="dropmsg1" class="dropcontent">
Java is completely different from JavaScript- it's more powerful, more complex, and unfortunately, a lot harder to master. It belongs in the same league as C, C++, and other more complex languages. Java programs need to be compiled before they can run, while JavaScript do not.
</div>

<div id="dropmsg2" class="dropcontent">
DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML. Through them a new level of interactivity is possible for the end user experience.
</div>
</form>

<form name="dropmsgform2">
<select name="dropmsgoption" size="1" style="width:300" onChange="expandone2()">
<option selected>What is JavaScript?</option>
<option>Difference betwen Java and JavaScript</option>
<option>What is DHTML?</option>
</select>
<br>

<div id="drop2msg0" class="dropcontent">
JavaScript is a scripting language originally developed by Netscape to add interactivity and power to web documents. It is purely client side, and runs completely on the client's browser and computer.
</div>

<div id="drop2msg1" class="dropcontent">
Java is completely different from JavaScript- it's more powerful, more complex, and unfortunately, a lot harder to master. It belongs in the same league as C, C++, and other more complex languages. Java programs need to be compiled before they can run, while JavaScript do not.
</div>

<div id="drop2msg2" class="dropcontent">
DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML. Through them a new level of interactivity is possible for the end user experience.
</div>
</form>

:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum