Hi folks,
I have a form for filling out a business card online.
Most fields are predefined to avoid typos and the work position list has a corresponding English value.
One of the titles in Norwegian has different add-ons in English so for the user to pick the correct one I want it to show the English value in parentheses.
I got some help here earlier for when the user picks his position at first and got this script (excerpt):
$q7=mysql_query("select id, name, en_name from met_pos WHERE parentid=0 ORDER BY name");
echo mysql_error();
while($nt7=mysql_fetch_array($q7)){
if ($nt7[name] == 'Seksjonssjef') {
echo "addOption(document.drop_list.Pos, '$nt7[id]', '$nt7[name] ($nt7[en_name])');";
} else {
echo "addOption(document.drop_list.Pos, '$nt7[id]', '$nt7[name]');";
}
}
If a user wants to change his title (or anything) before ordering the list shows up again with a selected value but this value comes from different function.
How can I add the same “functionality” to this function?
function SelectPos() {
<?php
$index = 1;
$resultPos=mysql_query("select id, name, en_name from met_pos ORDER BY name asc");
while ($row = mysql_fetch_array($resultPos)) {
?>
if (<?php echo $row['id']; ?> == <?php echo $_POST['Pos']; ?>)
{
var option = document.createElement("option");
option.text = "<?php echo $row['name']; ?>";
option.value = "<?php echo $row['id']; ?>";
document.drop_list.Pos.options.add(option);
document.drop_list.Pos.options[<?php echo $index; ?>].selected = true;
} else {
var option = document.createElement("option");
option.text = "<?php echo $row['name']; ?>";
option.value = "<?php echo $row['id']; ?>";
document.drop_list.Pos.options.add(option);
}
I have managed to put the English title in parentheses but then it applies for all values, not only the one I want.
option.text = "<?php echo $row['name']; ?> (<?php echo $row['en_name']; ?>)";
Appreciate any help.
Thanks!