?foru
05-16-2009, 03:06 AM
forum_amnesiac posted some code in another thread which is very similar to mine but I started a new thread as to not interfere with the other thread question.
This also creates a dynamic dropdown list
$carriers = array(
'Alltel' => '@message.alltel.com',
'Ameritech' => '@paging.acswireless.com',
'AT&T' => '@txt.att.net',
'Bellsouth' => '@sms.bellsouth.com',
);
Function for select
function carrierOptions($selected)
{
$html = '';
global $carriers;
foreach($carriers as $carrier => $email)
{
if($selected==$carrier) { $html .= '<option value="'.$carrier.'" SELECTED>'.$carrier.'</option>'; }
else { $html .= '<option value="'.$carrier.'">'.$carrier.'</option>'; }
}
return $html;
}
After submit I use the following vars to echo out who the message was sent to.
$carrier = $carriers[$carrier];
$to = $phone.$carrier;
$to would produce something like xxxxxxxxxx @ message.alltel.com (spaces to not create a link)
Everything works fine
but I would like to show the selected value from the dropdown also
echo "Carrier selected was: ".$name_var." and your message was sent to ".$to."";
//Carrier selected was: Alltel and and your message was sent to xxxxxxxxxx@message.alltel.com
With this array type I don't believe there is a way to show the carrier name that way since the array associates to the provider email address like => $email
Could the above function be re-written maybe to dynamically just provide the Carrier name that was selected? I appreciate any help, thank you.
This also creates a dynamic dropdown list
$carriers = array(
'Alltel' => '@message.alltel.com',
'Ameritech' => '@paging.acswireless.com',
'AT&T' => '@txt.att.net',
'Bellsouth' => '@sms.bellsouth.com',
);
Function for select
function carrierOptions($selected)
{
$html = '';
global $carriers;
foreach($carriers as $carrier => $email)
{
if($selected==$carrier) { $html .= '<option value="'.$carrier.'" SELECTED>'.$carrier.'</option>'; }
else { $html .= '<option value="'.$carrier.'">'.$carrier.'</option>'; }
}
return $html;
}
After submit I use the following vars to echo out who the message was sent to.
$carrier = $carriers[$carrier];
$to = $phone.$carrier;
$to would produce something like xxxxxxxxxx @ message.alltel.com (spaces to not create a link)
Everything works fine
but I would like to show the selected value from the dropdown also
echo "Carrier selected was: ".$name_var." and your message was sent to ".$to."";
//Carrier selected was: Alltel and and your message was sent to xxxxxxxxxx@message.alltel.com
With this array type I don't believe there is a way to show the carrier name that way since the array associates to the provider email address like => $email
Could the above function be re-written maybe to dynamically just provide the Carrier name that was selected? I appreciate any help, thank you.