0

My form looks like this:

<form target="xy.php">
<select name="aaa">
<option><?=$dabavalue[dabav];?></option>
<option>öäü</option>
<option>asd</option>
<option>asaaa</option>
</select>
</form>

I´m trying to change my "öäü" to "oeaeue" which could be selected before in an form (userdata) and saved. This values should be send to another form which generates a PDF document. I´ve got this to check boxes in the pdf:

<?if($aaa == "oeaeue"){$y="x"}?> 

because i cant work with äöü here...

--> How do i change äöü BEFORE the form is submitted or change the value of

<option><?=$dabavalue[dabav];?></option>

This didn´t work....

$dabavalue[dabav]; == ü

<?
                        if($aaa[y] == "&uuml;"){
                            $newStatus = "ue";
                        }
                        ?>

                        <td colspan="3" style="">
                            <select name="aaa">
                                <option value="<?=$newStatus;?>"><?=$dabavalue[dabav];?></option>
Top Questions
  • 1,862
  • 4
  • 26
  • 38

2 Answers2

1
var form = document.getElementsByTagName('form')[0];
form.addEventListener('submit', function(){
    var select = document.getElementsByName('aaa')[0];
    for(var i = 0; i < select.options.length; i++){
        var option = select.options[i];
        if(option.innerHTML === '<?=$dabavalue[dabav];?>') // or content of option you want to change
            option.innerHTML = 'newValue';
    }
});
karaxuna
  • 26,752
  • 13
  • 82
  • 117
  • this should work, thanks. I´ll try it like this, i thought i could maybe solve this with php...but this should work for me ,too. – Top Questions Apr 24 '13 at 10:45
0

Are you just asking how to change the selected value in a SELECT? If so you might want to look at this: How can I set the default value for an HTML <select> element?

HTH

Community
  • 1
  • 1
Al.
  • 330
  • 1
  • 13