0
votes

I am having trouble with forms!

The picture below is how i would like to have the interface set up. Basically it consists of a textarea, then a form with 'Submit' buttons, then a drop down box. The red outlined box is a div whose contents changes depending on the value selected from the dropdown box, whose current value is 'Player'.

I can't seem to get the following behaviour to work: depending on the number of checkboxes clicked, output a phrase in the textarea a certain number of times upon pressing the 'Defend' button.

enter image description here

Thanks for your time!

1
try to play with onchange function of the checkbox. I cant help much without your initial codeuser2404546
i would edit with code but i can't seem to figure out a sensible way to indent pages of code. Anyways if you are interested you can view my code here: codingforums.com/showthread.php?p=1341704#post1341704user2361103
@user2361103 you can use button '{}' on toolbar. Or simply place a code in any way into your question and someone will edit it.Viktor S.

1 Answers

0
votes

Here is an example of what might work (you will need to change it to suit your needs):

<script type = "text/javascript">
function checkboxes()
{
if(document.getElementById('checkbox_1_id').checked&&document.getElementById('checkbox_2_id').checked == false)
{
document.getElementById('textarea_id').value = "First checkbox has been checked";
}
else if(document.getElementById('checkbox_1_id').checked == false&&document.getElementById('checkbox_2_id').checked)
{
document.getElementById('textarea_id').value = "Second checkbox checked";
}
else if(document.getElementById('checkbox_1_id').checked&&document.getElementById('checkbox_2_id').checked)
{
document.getElementById('textarea_id').value = "Both checkboxes checked";
}
}
</script>

<input type = "checkbox" id = "checkbox_1_id" >
<input type = "checkbox" id = "checkbox_2_id" >
<input type = "button" onclick = "checkboxes()" value = "defend">