This topic is locked
[SOLVED]

 Updating Multiply Fields In List Page

6/20/2013 3:04:00 AM
PHPRunner General questions
C
chrispa author

i refer to that very nice and interesting topic
http://www.asprunner.com/forums/topic/14188-updating-multiple-selected-records-based-on-a-combobox-value-on-list-page/
i tryied but is not working i use phprunner 6.2
can you help ?
what i have done so far is

to add following dropdown combo box in list page
// dropdown to select category to update requested items
global $conn;

$str = "";

$str.= "<select name=\"JobDropDown\" id=\"JobDropDown\"><option value=\"\">Select Category :</option>";
//select values from database

$strSQL = "select categories from categories";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))

$str.="<option value=\"".$data["categories"]."\">".$data["categories"]."</option>";

$str.="</select>";

echo $str;
which is working and i can see the field names
i add a custom button next to combo box above which i need user to press and update the selected records with the value of the combo box
// on before client button event
var value = document.getElementById('JobDropDown').value;

alert (value);
//on server tab
global $dal;
for ($i=0; $i<count($keys); $i++)
{
// set ReportsTo field to 'Bob Smith'
$sql = "Update requsitions set category='Bob Smith' where ID="
. $keys[$i]["ID"];
CustomQuery($sql);
}
$result["txt"] = "Records were updated.";
// on client after
var message = result["txt"];
ctrl.setMessage(message);
i need help to change 'Bob Smith' with the value of the dropdown combo box
pls help

C
cgphp 6/20/2013

Check how button works here: http://xlinesoft.com/phprunner/docs/inserting_button.htm

At the bottom of the page there are a lot of examples.

C
chrispa author 6/20/2013



Check how button works here: http://xlinesoft.com/phprunner/docs/inserting_button.htm

At the bottom of the page there are a lot of examples.


THANKS
but i cannot see how to get the value from the dropdown combo box i created and update the records .
that is only i need can you help?

C
cgphp 6/20/2013

Before client

var dd = document.getElementById('JobDropDown');

params['selected_dd_value'] = dd.options[dd.selectedIndex].value;



Server

You get the selected dropdown value from the $params['selected_dd_value'] var.

C
chrispa author 6/20/2013



Before client

var dd = document.getElementById('JobDropDown');

params['selected_dd_value'] = dd.options[dd.selectedIndex].value;



Server

You get the selected dropdown value from the $params['selected_dd_value'] var.


thank you very much i changed to that
global $dal;
for ($i=0; $i<count($keys); $i++)
{
// set ReportsTo field to 'Bob Smith'
$sql = "Update requsitions set category=" . $params['selected_dd_value'] . " where ID="
. $keys[$i]["ID"];
CustomQuery($sql);
}
$result["txt"] = "Records were updated.";
but cannot still update , what i am doing wrong?

C
cgphp 6/20/2013

If category is a string and not a number, single quotes are missing. Please, try the following code:

$sql = "Update requsitions set category = '" . $params['selected_dd_value'] . "' where ID = " . $keys[$i]["ID"];
C
chrispa author 6/20/2013



If category is a string and not a number, single quotes are missing. Please, try the following code:

$sql = "Update requsitions set category = '" . $params['selected_dd_value'] . "' where ID = " . $keys[$i]["ID"];



THANKS YOU VERY MUCH !!!
IS WORKING GREAT !!!!