Geen bewerkingssamenvatting
Geen bewerkingssamenvatting
Regel 31: Regel 31:
end
end
end
end
local newOptionstable = {}
local res = '<select id="{id}" class="">' .. table.concat( newOptionsTable, "" ) .. '</select>'
return ""
end


return ""
--[[
]]--
p.createSelectOption = function( val, label, id, isSelected )
local attribures = {
['value'] = mw.text.trim( val ),
['for'] = id
}
if ( isSelected ) then
attribures['selected'] = 'selected'
end
local input = frame:extensionTag( 'option', label, attributes );
return input
end
end


return p
return p

Versie van 21 jan 2025 22:05

Module:FFSelect




<select name="selectFrut" id="selectme">{{#invoke:FFSelect|select
|options=apple>>>appel;pear>>>peer;banana>>>banaan
|labelled=true
|selected=pear
|sep=;
|id=selectme
}}</select>


local p = {}

--[[

{{#invoke:FFSelect
|selected=pear
|options=apple, pear, banana
|optionlabels=apple--apple; pear--pear; banana--banana
|sep=;
|id=
}}

<select id={id} >
  <option for={id} >
</select>

]]--
p.select = function(frame)
	local allValues = frame.args.values or "" --all possible values
	local options = frame.args.options or {}
	local sep = frame.args.sep or ','
	local optionsTable = mw.text.split( options, sep )
	local selected = frame.args.selected or ''
	selected = mw.text.trim(selectedVal)
	
	otherOptions = {}
	for k,v in ipairs( optionsTable ) do
		local option = mw.text.trim(v)
		if option ~= selected then
			otherOptions[k] = option
		end
	end
	
	local newOptionstable = {}
	
	local res = '<select id="{id}" class="">' .. table.concat( newOptionsTable, "" ) .. '</select>'
	return ""
end

--[[
]]--
p.createSelectOption = function( val, label, id, isSelected )
	local attribures = {
		['value'] = mw.text.trim( val ),
		['for'] = id
	}
	if ( isSelected ) then
		attribures['selected'] = 'selected'
	end
	local input = frame:extensionTag( 'option', label, attributes );
	return input
end

return p