Can I ask you a question about using JavaScript select box?

Asked 2 years ago, Updated 2 years ago, 31 views

I'm making a lottery ticket, but there's a block, so I'm asking you a question!

First, in the index.html shown on the first screen,

<form name="form">
<select id="selectBox" name="selectBox" onchange="OnChange();">
    <option>1</option>
<script>
    for(i=2;i<861;i++){
    document.write("<option>"+i+"</option>");
    }
</script>
</select>
</form>

<script>bbb=$("#selectBox").val();</script>
<script id="ddd"  defer="" type="text/javascript" document.write('src=""')></script>
<script type="text/javascript">
    document.getElementById("ddd").src="http://lotto.kaisyu.com/api?method=get&gno="+bbb+";callback=loadlot";
</script>
<p style="position:absolute;top:calc(50% + 100px);width:100%;">
    <input type="text" id="inputnum" value="5" size="2">number <span class="key" onclick="count()"> Start</span>
</p>

<section id="winner" class="shadow">
    <h2 id="lottok">loading...</h2>
    <div class="output" id="output0"></div>
    <div class="output" id="output1"></div>
    <div class="output" id="output2"></div>
    <div class="output" id="output3"></div>
    <div class="output" id="output4"></div>
    <div class="output" id="output5"></div>
    <div class="output" style="box-shadow:none; color:#000;">+</div>
    <div class="output" id="output6"></div>
</section>
<div id="stats"></div>

<ol id="lottotable"></ol>

You have these sources. When you access the first page, the first lottery number is automatically displayed in the bottom section winner

This section is done through a function in main.js where I am currently stuck

The box has been made from 1 to 860 times through the selection box above, and if you click 10 times, the number of lotto on the section winner below is

I'd like to change the number of the 10th Lotto. That's why bbb=$ ("#selectBox").Value selected in the select box through val();

I pulled it in and made it use src in combination with the existing address, but the problem is that the page has already been loaded once, so the winning number below does not change

So I thought the first way was to generate an event through onChange, but I couldn't figure it out

The second method is to save the selected value when selecting the serial box, reload it, and hand it over, which is also currently blocked

I was just doing c++, but it's too congested to do nodejs. Is there a good way?

node.js javascript

2022-09-21 16:11

1 Answers

What you're asking is not a select box issue, but it's actually about drawing elements dynamically or getting asynchronous requests from JS. That's roughly as follows.

Since you said Node.js... There is a way to receive API calls by bypassing the internal API instead of directly through JS. Please refer to it.


2022-09-21 16:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.