To select two select boxes to display messages, etc.

Asked 2 years ago, Updated 2 years ago, 278 views

To select two select boxes to display messages, etc.~I want to complete the fare search program~
Now, if you select it in the select box, you will see a message.

<script type="text/javascript"language="javascript">
    function onButtonClick(){
      sellindex= document.form1.Select1.selectedIndex;
      target= document.getElementById("output");
      switch(selindex){
        case0:
          target.innerHTML="Element 1 is selected.<br/>";
          break;
        case1:
          target.innerHTML="Element 2 is selected.<br/>";
          break;
        case2:
          target.innerHTML="Element 3 is selected.<br/>";
          break;
        case3:
          target.innerHTML="Element 4 is selected.<br/>";
          break;
        case4:
          target.innerHTML="Element 5 is selected.<br/>";
          break;
      }
    }
  </script>

What I want to combine with this is the next js sentence.What should I do?

<script type="text/javascript">

function kotae()<br>
{
ten = 0
if((f.q1.value=="Matsuyama City"&f.q2.value=="Takamatsu City")||(f.q1.value=="Takamatsu City"&f.q2.value=="Matsuyama City")
{f.q1.style.backgroundColor="aqua"; ten=ten+50}<br>
else f.q1.style.backgroundColor="red"
if(f.q3.value=="Nagoya City") {f.q3.style.backgroundColor="aqua"; ten=ten+25}<br>
else f.q3.style.backgroundColor="red"
if(f.q4.value=="Kanazawa City"){f.q4.style.backgroundColor="aqua"; ten=ten+25}<br>
else f.q4.style.backgroundColor="red"<br>
f.tokuten.value=ten
const keywords = ['Aiueo', 'Kakikakeko', 'Sasasusoso']; <br>
if(f.tokuten.value=50){
    for(leti=0;i<keywords.length;i++){
        console.log(f.rank.value=keywords[0]);
    }}
else if (f.tokuten.value>=20) {f.rank.value='B'}<br>
else if (f.tokuten.value>=15) {f.rank.value='C'}<br>
else if (f.tokuten.value<10) {f.rank.value='D'}<br>
// That's it
}
</script>
<body>
<form name="f"><br>
Ehime Prefecture's prefectural government office is located in 
<select name="q1">
<option>choice</option>
<option>Nagoya City</option>
<option>Matsuyama City</option>
<option>Kanazawa City</option>
<option>Takamatsu City</option>
</select>
is。
<p>
The prefectural government office in Kagawa Prefecture is located at 
<select name="q2">
<option>choice</option>
<option>Nagoya City</option>
<option>Matsuyama City</option>
<option>Kanazawa City</option>
<option>Takamatsu City</option>
</select>
Yes. <p>
The prefectural government office in Aichi Prefecture is located at 
<select name="q3">
<option>choice</option>
<option>Nagoya City</option>
<option>Matsuyama City</option>
<option>Kanazawa City</option>
<option>Takamatsu City</option>
</select>
Yes. <p>
Ishikawa Prefecture's prefectural government office is located in 
<select name="q4">
<option>choice</option>
<option>Nagoya City</option>
<option>Matsuyama City</option>
<option>Kanazawa City</option>
<option>Takamatsu City</option>
</select>
Yes. <p>
<input type="button" name="b1" value="answer" onclick="kotae()">p>
<input name=tokuten size="6"> points
<!--HTML From here-->
<input name=rank class="hoge">rank
<!--HTML up to -->

I would like to combine these so that if you select Matsuyama City and Takamatsu City in Question 1 and 2, the message will be displayed.

javascript html5

2022-09-30 22:04

1 Answers

Register the function document.f.q1.value as document.f.q2.value and document.f.q2.value as document.f.q1 and document.f.q2.


2022-09-30 22:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.