opensource2000
04-07-2008, 11:55 AM
Hi,
I am using PHP as the backend. I load the options for the combobox from a mysql database. After one of the option from the combobox is selected, I want to save the selected option in the database.
Before opening the application, the database field (where the selected option is saved) has a default value (ex: "Company1" is the selected option). However after I open the application, the database field is deleted ("Company1" becomes "") before I even choose the option from the combobox. So I guess the handler is executed before I even select anything from the combobox.
How can I change the code inside the <combobox> tags so that the option is sent to the querystring of input3 exactly after it's selected from the combobox ?
...
dataset name="d1" request="true" type="http" src="http://.../getcontactinfo.php" />
<dataset name="d3" request="false" type="http" src="http://.../updateinfo.php"/>
...
<combobox width="130" editable="false">
<textlistitem datapath="d1:/contact_info/company" text="$path{'@Company_Name'}" value="$path{'@Company_Name'}"/>
<handler name="onselect">
var company_selected = this.getText();
var d3=canvas.datasets.d3;
var parameter=new LzParam();
parameter.addValue("company_selected", company_selected, true);
d3.setAttribute('querystring', p);
d3.doRequest();
</handler>
</combobox>
updateinfo.php
<?php
{
$company_selected =$_GET["company_selected"];
include("connect_db.php"); // connect to database
mysql_query(" UPDATE user_settings SET Company_Selection ='$company_selected' WHERE userid='user1'");
}
?>
Thanks a lot for any comments
I am using PHP as the backend. I load the options for the combobox from a mysql database. After one of the option from the combobox is selected, I want to save the selected option in the database.
Before opening the application, the database field (where the selected option is saved) has a default value (ex: "Company1" is the selected option). However after I open the application, the database field is deleted ("Company1" becomes "") before I even choose the option from the combobox. So I guess the handler is executed before I even select anything from the combobox.
How can I change the code inside the <combobox> tags so that the option is sent to the querystring of input3 exactly after it's selected from the combobox ?
...
dataset name="d1" request="true" type="http" src="http://.../getcontactinfo.php" />
<dataset name="d3" request="false" type="http" src="http://.../updateinfo.php"/>
...
<combobox width="130" editable="false">
<textlistitem datapath="d1:/contact_info/company" text="$path{'@Company_Name'}" value="$path{'@Company_Name'}"/>
<handler name="onselect">
var company_selected = this.getText();
var d3=canvas.datasets.d3;
var parameter=new LzParam();
parameter.addValue("company_selected", company_selected, true);
d3.setAttribute('querystring', p);
d3.doRequest();
</handler>
</combobox>
updateinfo.php
<?php
{
$company_selected =$_GET["company_selected"];
include("connect_db.php"); // connect to database
mysql_query(" UPDATE user_settings SET Company_Selection ='$company_selected' WHERE userid='user1'");
}
?>
Thanks a lot for any comments