我有一个射频到L波段的计算器/转换器,我正在为我的FT工作而设计和开发。现在C波段很简单,因为我们只使用一个频率范围。KU波段我们有两个频率范围。因此,对于那个计算器,我想使用单选按钮。当工程师检查无线电1时,他们使用为该频率范围编码的功能,如果他们检查无线电2,他们使用为该频率范围编码的功能。
当无线电是.checked的时候,我该怎么调用它呢?
我应该创建一个变量数组来将函数分配给吗?我是JS的新手。所以,如果我说得不清楚,请告诉我。蒂娅。
发布于 2021-11-24 21:02:55
NVM。我想我想出了一个解决办法。
我将使用"If a is check var b= freqOne else b= freqTwo“。
发布于 2021-11-24 21:05:25
您可以将函数名与单选按钮值进行匹配
function foo() {
console.log("foo was called");
}
function bar() {
console.log("bar was called");
}
function loremipsum() {
console.log("loremipsum was called")
}
function test(item) {
window[item.value]();
}<label>Foo <input type="radio" name="something" value="foo" onclick="test(this)"></label>
<label>Bar <input type="radio" name="something" value="bar" onclick="test(this)"></label>
<label>Lorem <input type="radio" name="something" value="loremipsum" onclick="test(this)"></label>
https://stackoverflow.com/questions/70102825
复制相似问题