Top Questions
Top Questions

Reputation: 1852

Change value before submit form with target

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>

Upvotes: 0

Views: 802

Answers (2)

Al.
Al.

Reputation: 330

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

Upvotes: 0

karaxuna
karaxuna

Reputation: 26940

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';
    }
});

Upvotes: 1

Related Questions