Use select field as to update another table

Hi There,

I have a select field where i want to update a table field when the value is changed.

So i put this code in the ajax onchange

now the wierd thing is that the value of the select field is not reconized. i tried everything. any suggestions?

// SQL statement parameters
$update_table = ‘ILP_rooster_deelnemer’; // Table name
$update_where = “wk_id = {value_from_select_field}”; // Where clause
$update_fields = array( // Field list, add as many as needed
“wk_status = 4”,
“wk_opm_status = ‘rtr was here’”,

);

// Update record
$update_sql = ‘UPDATE ’ . $update_table
. ’ SET ’ . implode(’, ', $update_fields)
. ’ WHERE ’ . $update_where;
sc_exec_sql($update_sql);

Try to separate the form variable out of the double quotes.
$myval={value_from_selected_field}
$update_where=‘wk_id=’.$myval.
Depending on the datatype you might need to add quotes.

thanks @aducom that worked for now. i find another wierd thing that i solved. if you use a WHERE and the field is not in the shown list. eg. selected as a shown field. i did’t work. if u show the field and hide it it works fine…

Yes, to be able to use a field, it needs to be in the selected list. That is how Scriptcase works. If it is not selected, the field will not be generated and thus unusable.