Sha256: ac7953ce57a5a6d46a65e0ee4e7a94a2eeeff8f36162ee4a141753fdfe77bbaf

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

# = Select
#
# code: gmosx
#
# (c) 2004 Navel, all rights reserved.
# $Id: select.rb 71 2004-10-18 10:50:22Z gmosx $

module N; module UI

class Select

# Generalized select. Dont create the enclosing selects to
# be flexible.
# Example:
#
# <select name="param" onchange="submit()">
# 	#{N::UI::Select.render_options(
#		paramvalue,
#		[-1, 1, 2, 3],
#		["-- Enter Options --", "Man", "Woman", "None"]
#	)}
# </select>
#
def self.render_options(paramvalue, values, options)
	str = ""
	
	values.each_with_index { |val, idx|
		if paramvalue == val
			str << %{<option value="#{val}" selected="1">#{options[idx]}</option>}
		else
			str << %{<option value="#{val}">#{options[idx]}</option>}
		end
	}
	
	return str
end

end 

end; end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.1.2 lib/n/ui/select.rb