Reputation: 461
i am doing a select
in html then I have something in the JS part like this
var languageEN = "en,1";
var languageFR = "fr,2";
var languageDE = "de,3";
and my html markup will be like
<select style="display: none;" id="select">
<option value=languageEN>English</option>
<option value=languageFR>Francais</option>
<option value=languageDE>Deutsch</option>
</select>
but it seems that I am hitting undefined.
I been trying to find whats the correct syntax to include in the option value
but no avail. thanks.
Upvotes: 0
Views: 92
Reputation: 18695
If using PHP is an option you could do this. The first part could go at the top of the page, then the second part wherever the select needed to be. You could add as many options or change them any way you liked this way.
<?php
$options = array(
0 => array(
'name' => 'English',
'value' => 'languageEN'
),
1 => array(
'name' => 'Francais',
'value' => 'languageFR'
),
2 => array(
'name' => 'Deutsch',
'value' => 'languageDE'
),
);?>
<select style="display: none;" id="select">
<?php
foreach ($options as $option);
{
echo '<option value="'.$option['value'].'">".$option['name'].'</option>'
}
?>
</select>
Upvotes: 2