根据在 Openwrt Luci 中选择的单选选项,文本框需要可见或隐藏
A textbox need to be visible or Hidden based on radio option selected in Openwrt Luci
我想根据在 openWRT Luci 中选择的单选选项使文本框可见或隐藏。
有什么办法可以避免JavaScript?
提前致谢
yah Raihanhbh 它在 openwrt luci 中可用,你需要使用 dependent。基于 luci documentation 让我们描述依赖如何工作。
CBI 在选项对象上提供 :depends() 方法,允许根据其他字段中的值动态显示或隐藏对象字段。
该方法被称为 obj:depends( some_other_option, value )。 "depends" 参数链接到 "OR"
--举个例子
local t=require"luci.model.network".init()
local e=require"luci.model.firewall".init()
local i=require"luci.util"
local e=require"luci.model.uci".cursor()
local u=require"luci.sys".net
--创建模型
m = Map("firewall1", translate("firewall"))
s = m:section(NamedSection, "dmz", "")
--创建单选按钮
f1 = s:option(ListValue, "dmz", "Current DMZ Status:") -- Creates an element list (select box)
f1.widget="radio"
f1:value("disable", "Disable") -- Key and value pairs
f1:value("enable", "Enable")
f1.default = "disable"
function f1.write(self, section, value)
return Flag.write(self, section, value)
end
--文本框
f2=s:option(Value,"netmask1")
f2:depends("dmz","disable")
function f2.cfgvalue(self,section)
local val = self.map:get(section, "netmask")--Value.cfgvalue(self, section)
return val
end
--Return型号
return m;
上面的文本框 netmask1 取决于单选按钮 dmz
我想根据在 openWRT Luci 中选择的单选选项使文本框可见或隐藏。
有什么办法可以避免JavaScript?
提前致谢
yah Raihanhbh 它在 openwrt luci 中可用,你需要使用 dependent。基于 luci documentation 让我们描述依赖如何工作。
CBI 在选项对象上提供 :depends() 方法,允许根据其他字段中的值动态显示或隐藏对象字段。
该方法被称为 obj:depends( some_other_option, value )。 "depends" 参数链接到 "OR"
--举个例子
local t=require"luci.model.network".init()
local e=require"luci.model.firewall".init()
local i=require"luci.util"
local e=require"luci.model.uci".cursor()
local u=require"luci.sys".net
--创建模型
m = Map("firewall1", translate("firewall"))
s = m:section(NamedSection, "dmz", "")
--创建单选按钮
f1 = s:option(ListValue, "dmz", "Current DMZ Status:") -- Creates an element list (select box)
f1.widget="radio"
f1:value("disable", "Disable") -- Key and value pairs
f1:value("enable", "Enable")
f1.default = "disable"
function f1.write(self, section, value)
return Flag.write(self, section, value)
end
--文本框
f2=s:option(Value,"netmask1")
f2:depends("dmz","disable")
function f2.cfgvalue(self,section)
local val = self.map:get(section, "netmask")--Value.cfgvalue(self, section)
return val
end
--Return型号
return m;
上面的文本框 netmask1 取决于单选按钮 dmz