Sorry for the rudimentary question.
I would like to send and receive values between html files, but there are various restrictions and I can't use webstorage and cookies, so I decided to attach parameters when linking.
When sending parameters
I want to send a value named A and a value named B
Set the value of A to vara;
The value of B is var B;
The result of pressing the radio button is defined in the if statement and the value has been substituted.
var prom="A="+a+"&B="+b;
(I don't understand the code above.)
<a href="〇 h.html?+pram";>
Once executed, the receiver html can simply retrieve the string pram.
Please let me know how to write it.
javascript html
JavaScript code only applies to the following parts of an HTML document:
<script>
In-tag/<script>
linked external resourceson
such as onclick
javascript:
Other than these, JavaScript variables cannot be written. The href
attribute in the a
element is for URLs, but you cannot write variables because it does not start with javascript:
.
You must change the href
using DOM.Modify the attribute values as follows, making it easy to see from the code, such as adding an id to the desired a
element:
<aid=foobar>
<script>
varprom="A="+a+"&B="+b;
document.getElementById('foobar').setAttribute('href', '〇 ..html?'+prom);
</script>
© 2024 OneMinuteCode. All rights reserved.