i am trying to output the values from form elements , i manage to output the single values from select elements but how can i output multiple values if more than one checkbox is selected. See if anyone could help ? maybe i need to pass the checkbox values via array !
<head><title></title></head>
<style>
#box{
border:solid 1px red;
height:16px;
}
</style>
<body>
size : <select id = "test1">
<option>Large</option>
<option>Medium</option>
<option>small</option>
</select>
Base : <select id = "test2">
<option>Thick</option>
<option>Thin</option>
</select>
Tomato:<Input type ="checkbox">
Onion:<Input type ="checkbox">
Paprika:<Input type ="checkbox">
<input type="submit" value = "Submit" onclick ="buttonClick()" />
<br /> <br />
<div id ="box"></div>
<script type = "text/javascript">
function Pizza(s,t){
this.size = s;
this.type = t;
}
Pizza.prototype.myPizza = function(){
document.getElementById('box').innerHTML = "This is a " + this.size + " Pizza with " + this.type + " base and the toppings include: ";
}
function buttonClick(){
x = document.getElementById('test1').value;
y = document.getElementById('test2').value;
Tuesday = new Pizza(x,y);
Tuesday.myPizza();
}
</script>
</body>
</html>
Code can also be viewed here : http://jsfiddle.net/bhEeZ/2/
This should do it: jsFiddle example