sc_ajax_select_boxes reference
Submitted by panos on Sat, 11/17/2007 - 00:13.
Public methods:
-
add_select_box, add_radio_box
Syntax: add_select_box(db_table_name, key_field_name,
description_field_name, order_field_name,
selected_value, tag_name, tag_id, [extra_tag_attributes]
, [extra_where], [select_prompt_text])
Syntax: add_radio_box(db_table_name, key_field_name,
description_field_name, order_field_name,
selected_value, tag_name, tag_id, [extra_tag_attributes]
, [extra_where], [select_prompt_text])
Adds a select/radio box definition.
Parameters:
-
db_table_name is the database table where select box options are stored.
-
key_field_name is the field which holds key values for select box options.
-
description_field_name is the field which holds description text for select box options.
-
order_field_name is the field you want to be used to order option list. If table is already indexed or you want options shown in the same order that are stored in db set order_field_name value to "".
-
selected_value is the initialy selected option, if set to '' then Please select... option will be selected.
The SQL statement that is created to load options has the form:
SELECT key_field_name, description_field_name
FROM db_table_name
[ORDER BY order_field_name]
Caution: This value is not used when select box is linked using link_select_boxes method. Set selected value with link_select_boxes.
-
tag_name HTML name attribute for the select box. Also used by the class to reference select box definitions.
-
tag_id HTML id attribute for the select box.
-
[extra_tag_attributes] any formating attributes you might need, style,width etc.
-
[extra_where] Extra filtering. Simply extra_field=value
The SQL statement that is created to load options if extra where is added has the form:
SELECT key_field_name, description_field_name
FROM db_table_name
WHERE extra_where
[ORDER BY order_field_name]
-
[select_prompt_text] Prompt text for select box replacing 'Please select'.
The class does not open mysql connection by it self, it expects a connection that is all ready open.
-
link_select_boxes
Syntax: link_select_boxes(parent_box_name, child_box_name,
link_field_name, selected_value)
Links two select boxes so when users selects a value on parent box, child box will load the appropriate values from the database.
Child box can act as a parent for an other box, like in the example.
If select box is a linked by an other box (see link_select_boxes) then a WHERE clause is added.
SELECT key_field_name, description_field_name
FROM db_table_name
WHERE link_field_name=selected_value
[ORDER BY order_field_name]
selected_value is the initialy selected value, helpful for record editing. When user selects another option to parent select box the selected_value is changed to the new one and child options are reloaded.
Caution: Selected value set with add_select_box is not used when select box is linked using link_select_boxes method. Set selected value with link_select_boxes method.
And if extra_where parameter is used for that select box will be
SELECT key_field_name, description_field_name
FROM db_table_name
WHERE link_field_name=selected_value
AND extra_where
[ORDER BY order_field_name]
-
place_jscripts
Syntax: place_jscripts()
Outputs all needed javascripts. You can place place_jscripts call to the right place where you want javascripts to be placed on your page.
-
show_select_box
Syntax: show_select_box(box_name)
Outputs html code for the box_name select box. Must make a call for each defined select box. The reason for that is
that you can place them where you need in your layout.
Properties:
There are some properties that allow you to customize strings displayed.
Bookmark/Search this post with:
|
First of all, Happy new year
First of all, Happy new year to all.. Thanks for the information. These are some very useful informations. Some informations were completely unknown to me. With the help of this page now i can handle things more better. Thanks again..keep up the good work.