Guys,
I am having a tough time getting the value of this drop down box. Here is the drop down code i got..
<select size="1" name="DDList" id="DDList"
onChange="xajax_changeScrapAccess(this.options[this.options.selectedIndex].value)">
{$DD_options}
Where DD_options is as below
<option selected>friends</option>
<option>friends of friends</option>
<option>everyone</option>
Now here is the function
function changeScrapAccess($arg)
{
$access_mode = $arg['scrpr'];
if($access_mode=="everyone")
{
$access_mode = "EVERY";
}
}
I just want to get the value in $access_mode liek if the user select private, i should get the value private in access_mode variable?
Help will be much appreciated
Thanks
Aman
To call the Value of the drop down box in function
Moderator: General Moderators
Re: To call the Value of the drop down box in function
To do that traditionally, you must submit a form to pass it to a php script. To do it "on the fly", you'll need to utilize AJAX, which is a world in its own.
EDIT: Ugh I didn't realize you're already using ajax functions! Hehe sorry if my reply doesn't help.
EDIT: Ugh I didn't realize you're already using ajax functions! Hehe sorry if my reply doesn't help.
Re: To call the Value of the drop down box in function
I am already using ajax...i just need the value once its been submittied through the form.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: To call the Value of the drop down box in function
Can you please wrap your original posted code in bbCode tags? You can highlight the code then click on the CODE button that is just above the textarea.
Can't you just hit the $_POST array?
Can't you just hit the $_POST array?
Re: To call the Value of the drop down box in function
Code: Select all
<form method="post">
<select size="1" name="DDList" id="DDList" onChange="xajax_changeScrapAccess(this.options [this.options.selectedIndex].value)">
<option selected>friends</option>
<option>friends of friends</option>
<option>everyone</option>
/select>
<?
$xajax->registerFunction("changeScrapAccess");
function changeScrapAccess($arg)
{
global $conn;
global $profile_id, $profile_info;
$access_mode = $arg['scrpr'];
if($access_mode=="everyone")
{
$access_mode = "EVERY";
}
elseif($access_mode =="friends")
{
$access_mode = "FRIENDS";
}
elseif($access_mode=="friends of friends")
{
$access_mode = "NEXTFRIENDS";
}
else $access_mode = $access_mode;
$UID = $_SESSION['UID'];
$sql = "INSERT INTO privacy SET security_scraps = '".$access_mode."', UID = '".$_SESSION['UID']."' ON DUPLICATE KEY UPDATE security_scraps= '".$access_mode."'";
$objResponse = new xajaxResponse();
if( $conn->Execute($sql) ) $objResponse->addAlert('Successfully changed!');
else $objResponse->addAlert('Error happened');
return $objResponse;
}
?>