Sha256: 783ea1b792db14e88c7ae401b9c0a5e5fd957e4c1dd23f58f706e9a12e999ce7

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 Bytes

Contents

# code: 
# * George Moschovitis  <gm@navel.gr>
#
# (c) 2004 Navel, all rights reserved.
# $Id: select.rb 152 2004-11-13 20:02:35Z 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

3 entries across 3 versions & 1 rubygems

Version Path
nitro-0.4.1 lib/nitro/ui/select.rb
nitro-0.5.0 lib/nitro/ui/select.rb
nitro-0.6.0 lib/nitro/ui/select.rb