:: Forum >> Version 1 >>

Submit a Selected Row's Value

Ok, after a heck of a lot of trail and error (not having a clue on what's potting with javascript didn't help), I finally got what I wanted to work. the other forum submittions didn't help me diddly squat - so I quested to make this work...

What I had done:
I had successfully put the data of a MySQL table into the table widget component like I wanted. the instructions are pretty simple to do - as it's commented in the PHP script.

What I wanted:
To get the id value (the very first field's value) of the row that I was selecting and place it into a hidden variable.

So we're doing this with PHP right. within the 'examples' folder there is a 'php' folder - in that there are two php files. ActiveWidgets and basic.

Take a look at the ActiveWidgets... it has a function there that will place all the data in there that you want.

You need to put the following code in just before this line:

$html .= " document.write($name);\n";

here's the code you need to place in before the line above:

$html .= "
$name.setAction(
\"click\", function(src)
{
form_widget.widget_id.value = ".$name."_data[src.getItemProperty ('index')][0];
}
);
";


Make sure you're echo-ing out (or assigning - if your using SmartTemplates) the widget on a form... call the form 'form_widget'... then have a hidden variable in there called 'widget_id' - now because I was wanting to capture the first field's value (it was my mysql database id value) I set the

form_widget.widget_id.value
'form'.'hidden_variable'.value

to

".$name."_data[src.getItemProperty ('index')][0];
object[ row ][ field_id_value ];


- for some reason the object's properties are object[row][field] - I would think it should be field and then row - arrays are better organised like [field][row] - if you read the code above you'll immediatly pick that up. src.getItemProperty ('index') is the row value that has been selected.

I had a serious problem with the selection of an item. because I would run the code with this other method, but it would stop the widget from displaying the selected row... you'd click on a row and it wouldn't highlight blue... This solves the problem though...

Anyway I hope this saves you a day or two...
Paul Urban
Friday, March 3, 2006



This topic is archived.

Back to support forum

Forum search