1

I'm having trouble with the current PHP dropdown and I'm posting this to get some shine of light.

Here's the HTML dropdown code

<select name="campaign_id">
    <?php foreach ( $campaigns as $campaignID => $value) { ?>
    <option value="<?php echo $campaignID;?>"><?php echo $value->name;?></option>    
    <?php } ?>
</select>

This value will be fetch from the GetResponseAPI.

$campaigns = empty value.
$campaignID= list of campaign ID but not in string
$value->name = I'm getting the campaign name [I need the string value of the campaign]

I also save the dropdown value to initialize with the following:

$drop = $_POST['campaign_id'];

Now $drop only carry the campaign token ID for example 9h6R but when I echo $value->name , i get the campaign name such as "Carrols_Campaign".

Is it possible for me to save the campaign name from the dropdown list when the user made his choice.

Is there any other method where I can save the campaign name which occurs in the array?? Thanks in advance

user3546239
  • 159
  • 1
  • 10

2 Answers2

1

if you want to save both the values then do like this

<script>

function call(t)
{
  var name=t.options[t.selectedIndex].innerHTML;
  document.getElementById('hid1').value=name;
}

</script>

 <select name="campaign_id" onchange="call(this)">
  <option value=1>one</option>
  <option value=2>two</option>
  <option value=3>three</option>v
 </select>

 <input type="hidden" id="hid1" name="hid1">

then in your php file you can get these two value like below

$selece_id = $_POST['campaign_id'];
$select_name = $_POST['hid1'];
ɹɐqʞɐ zoɹǝɟ
  • 4,342
  • 3
  • 22
  • 35
  • I'm using array fetching information from the API . I already found the right answer. How to close a thread @.@?? – user3546239 May 26 '14 at 07:12
0

I use the API function from get response

$result =  $api->getCampaigns('EQUALS',$drop);

where the dropdown value looks something like this:

<option value="<?php echo $value->name;?>"><?php echo $value->name;?></option>   

because when I use the option value for $value->name; and then i echo again the same value to know the name of value. So i saved the value and use it @ $results.

user3546239
  • 159
  • 1
  • 10