Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
Ajax Linked Select boxes :  forum.Salix.gr forum.Salix.gr
Comments, questions, usage, bugs. 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messageindex values
Posted by: csoreto (IP Logged)
Date: November 23, 2008 08:56PM

Hello,

I have a table with the following fields: 'id_fac' and 'nome_fac'; 'nome_fac' is displayed in 'sel1' box, however I don't know where to retrieve its associated index ('id_fac').
Could you tell me please which is the variable where is the value ('id_fac') to pass to mySQL database?

Many thanks,
carlos soreto

messageRe: index values
Posted by: panos (IP Logged)
Date: November 24, 2008 02:12AM

Hi Carlos,
if you mean which parameter in addSelectBox

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])

it is the second parameter.

Was that your question?

messageRe: index values
Posted by: csoreto (IP Logged)
Date: November 24, 2008 07:41AM

Panos,

My code is:

$sc_ajax_select_boxes->add_select_box('faculdades','id_fac','nome_fac','id_fac','','sel1','sel_id_1','');
$sc_ajax_select_boxes->add_select_box('cursos','id_curso','nome_curso','nome_curso','','sel2','sel_id_2','','');

and I would like to know how can I save the fileds 'id-fac' and 'id_curso' into another table.

(In other words: what are, in this case, the name of the 'key_field_name' for 'id_fac' and 'id_curso'?)

Regards,

messageRe: index values
Posted by: panos (IP Logged)
Date: November 26, 2008 02:34AM

the id_fac is in $_POST['sel1'] and id_curso in $_POST['sel2'].

was that the answer?

messageRe: index values
Posted by: csoreto (IP Logged)
Date: November 26, 2008 07:39AM

Panos,

Thank you very much for the answer.

Another question:
1) It is possible to remove duplicate rows from the result set displayed in 'sel1' or must I create a new table using the 'SELECT DISTINCTROW' option (as usual)?

2) Although not important, I would like to know if I can display different 'select' messages in 'sel1' and 'sel2'.

Best regards,

messageRe: index values
Posted by: panos (IP Logged)
Date: November 26, 2008 10:08AM

for 1. yes but you must hack. Function named get_list_from_db build the select statement, you can add the distinct
and for 2 I think yes. some parameter in add_select_box function.

Best regards
Panos

messageRe: index values
Posted by: csoreto (IP Logged)
Date: November 26, 2008 11:36AM

Panos,

Point 2 it's ok - it works.

Regarding Point 1, I get lost in a labyrinth! smiling smiley
Could you be more specific please, when do you say 'hack' (Do you mean writing a new 'sc_classes.php'?).

Best regards,

messageRe: index values
Posted by: panos (IP Logged)
Date: November 26, 2008 01:24PM

Hi csoreto,
c is for carlos? cassanova maybe? winking smiley

no worries i even get lost in that code smiling smiley

In function get_list_from_db (the one in sc_ajax_select_boxes class) around line 273 there is a line

$cmd = "SELECT $key_fld, $text_fld FROM $table ";

there you should add the distinct clause and make it like

$cmd = "SELECT DISTINCT $key_fld, $text_fld FROM $table ";

and it should do the trick.

Best regards
Panos



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum