 |
HTML Help Please Search for the answer to your question before asking it! Thanks.
|
| View previous topic :: View next topic |
| Author |
Message |
Etchedglass
Joined: 21 Aug 2008
Posts: 1
|
| Posted: Thu Aug 21, 2008 3:07 pm Javascript Checkbox problems |
|
|
First off, I should say that I'm a complete novice (at best >_>) when it comes to javascript, so this issue may be a piece of cake to fix for some of you.
I'm trying to make an application form with various fields to fill out, including several select drop down choices, and at least 1 "check all that apply" sort of category. Then at the very end, there's a button that needs to take all that information ya just picked and replace all those interactive boxes with simple printer friendly text in their respective locations
I've got the text input and select versions working the way I'm looking for with this code:
Code:
<script language="javascript">
<!--
function fill(){
var vresp0 = document.getElementById("resp0")
var vresp1 = document.getElementById("resp1")
var vresp2 = document.getElementById("resp2")
var vresp3 = document.getElementById("resp3")
var vresp4 = document.getElementById("resp4")
var vresp5 = document.getElementById("resp5")
var myAnswers = new Array()
myAnswers[0] = vresp0.value
myAnswers[1] = vresp1.value
myAnswers[2] = vresp2.value
myAnswers[3] = vresp3.value
myAnswers[4] = vresp4.value
myAnswers[5] = vresp5.value
document.getElementById("textDump").innerHTML = 'Field 1:' + ' ' + myAnswers[0];
document.getElementById("textDump2").innerHTML = 'Field 2:' + ' ' + myAnswers[1] + myAnswers[2];
document.getElementById("textDump3").innerHTML = 'Field 3:' + ' ' + myAnswers[3];
document.getElementById("textDump4").innerHTML = 'Field 4:' + ' ' + myAnswers[4];
document.getElementById("textDump5").innerHTML = 'Field 5:' + ' ' + myAnswers[5];
document.getElementById("textDump6").innerHTML = 'Field 6:' + ' ' + myAnswers[5];
}
//-->
</script>
<div id="textDump">
Field 1 <input type="text" id="resp0" />
</div>
<div id="textDump2">Field 2
<select id="resp1" value="field2">
<option>Please Choose</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
<select id="resp2" value="field2Sub">
<option>Please Choose</option>
<option> </option>
<option>: Option 1</option>
<option>: Option 2</option>
<option>: Option 3</option>
<option>: Option 4</option>
</select>
</div>
<div id="textDump3">Field 3
<select id="resp3" value="field4">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
<option>Option 5</option>
<option>Option 6</option>
</select>
</div>
<div id="textDump4">Field 4
<select id="resp4" value="field5">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
</div>
<div id="textDump5">Field 5 <input id="resp5" value="field6" /></div>
<div id="textDump6"><button onclick="fill()">finalize
</button></div>
But when I try to do the same thing with check boxes as the input type, I can't seem to get it to work out right. :oops:
I'd love any help or advice anyone can give to get this workin the way I see it in my head :D |
|
|
| |
|
|
|
Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group
|