This topic is locked
[SOLVED]

 How to pass value from dropdown to mysql query

2/9/2012 1:03:23 PM
PHPRunner General questions
S
smith author

Like to pass dropdown value from the list page to a custom button which will update selected record on list page. Dropdown ID is dropdown1.
So in the button
Client before tab


var e = document.getElementById("dropdown1");

var finalv = e.options[e.selectedIndex].value;


In the Server Tab



global $dal;
for ($i=0; $i<count($keys); $i++)
{
// set ReportsTo field to 'Bob Smith'
$sql = "Update Table set field = (????value from cliient before???) where id=".$keys[$i]["id"];
CustomQuery($sql);
}

$result["txt"] = "Records were updated.";


Now how to pass dropdown value from 'Client Before' tab to the sql query ie (????value from cliient before???)
Smith

C
cgphp 2/9/2012

In the "Client before" tab:

params['dropdown_value'] = $("#dropdown1").val();


In the "Server" tab:



global $dal;
for ($i=0; $i<count($keys); $i++)

{

// set ReportsTo field to 'Bob Smith'
$sql = "Update Table set field = '".$params['dropdown_value']."' where id=".$keys[$i]["id"];
CustomQuery($sql);

}

$result["txt"] = "Records were updated.";
S
smith author 2/9/2012

Thank you very much Cristian Gilè <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=64245&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=64245&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' />



In the "Client before" tab:

params['dropdown_value'] = $("#dropdown1").val();


In the "Server" tab:



global $dal;
for ($i=0; $i<count($keys); $i++)

{

// set ReportsTo field to 'Bob Smith'
$sql = "Update Table set field = '".$params['dropdown_value']."' where id=".$keys[$i]["id"];
CustomQuery($sql);

}

$result["txt"] = "Records were updated.";