I have a form that I need to link to multiple tables. For some reason, the server connect isn’t recognizing variables correctly. (It works the second time, not the first time when accessing the api.)
column 1: select box populated from server connect API (works)
column 2: another select box
- When column 1 select is updated, this calls a different server connect to get values, then automatically populates drop-down list from the server connect. I had to use javascript to populate this select box. (below)
column 3: a third select box based on what’s selected in column 2
for column 2, I’ve tried a ton of !@#$ to get this to work.
- I couldn’t bind the server connect directly - this updates all of the drop down options for all rows.
- I tried creating one server connect per row with a dynamic id, however, I found that when the id is dynamically generated, a select won’t bind to it.
- I tried setting a hidden input on value change, however, this isn’t working. I see the value is updated in the field, however the sever connect isn’t pulling the value from the field.
The only way I could get this to work was to use javascript to set the server control variable directly
Here’s the code that I’m using in my javascript:
<script>
function set_action_id(obj){
debugger;
index = obj.bindings.$index.value;
val=obj.data.value;
//tried setting hidden fields- that didn't work...
document.all['txt_action_id'].value=val;
document.all['txt_action_index'].value=index;
dmxComp=document.all['sc_get_action_type'].dmxComponent;
dmxComp.props.params['action_id']=Number(val);
dmx.parse('sc_get_action_type.load()');
}
function load_ddl(){
debugger;
var index=Number(document.all['txt_action_index'].value);
sel=document.all['sel_action_type'][index];
var options = document.all['sc_get_action_type'].dmxComponent.data.data.query_get_action_types_by_action_id;
sel.innerHTML="";
for(i=0;i<options.length;i++)
{
var opt = document.createElement('option');
opt.value = options[i].option_table_name;
opt.text=options[i].name;
sel.appendChild(opt);
}
}
</script>
In my server connect, I tried setting the parameter to a variable and using that. I also tried using a hidden field. None of these worked. Trying to figure out why these values aren’t being recognized when the server control is loaded. Is there a better way to do this?
Last updated: