Search code examples
javascriptphponchange

Problems with form in php script and using a javascript onchange href event


I have problems with an - I have to say - really old code I programmed many years ago (it worked back then) Here it is:

<form name="eingabe" method="post" action="index.php?aktion=linkliste" enctype="multipart/form-data">
    <table width="80%" align="center" border="1" cellspacing="0" cellpadding="0">
        <tr><td colspan="3" align="center" style="font-size:14pt;font-weight:bold;">Was möchten Sie bearbeiten</td></tr>
        <tr>
            <td colspan="3" align="center">
                <select name="geraetebearb" onChange=location.href("index.php?aktion=geraeteverleih&geraetebearb="+this.options[this.selectedIndex].value+"")>
                    <option value="0">Bitte auswählen:?</option>
                    <option value="tbl_geruest">Leihgebühren Gerüst</option>
                    <option value="tbl_geraete">Leihgebühren Geräte</option>
                </select>
            </td>
        </tr>
    </table>
</form>

When I changed the option in the selection group the onchange method automatically called the new url and I got to the category I wanted to change. But now -> nothing happens? Has anybody a tip for me, what I have to change to get it working again? Thank you all for your input.

René


Solution

  • So, I found the answer by myself, if someone else needs it:

    replace the location.href( with window.location= (also remove the ")" at the end....)

    <form name="eingabe" method="post" action="index.php?aktion=linkliste" enctype="multipart/form-data">
        <table width="80%" align="center" border="1" cellspacing="0" cellpadding="0">
            <tr><td colspan="3" align="center" style="font-size:14pt;font-weight:bold;">Was möchten Sie bearbeiten</td></tr>
            <tr>
                <td colspan="3" align="center">
                    <select name="geraetebearb" onChange=window.location="index.php?aktion=geraeteverleih&geraetebearb="+this.options[this.selectedIndex].value+"">
                        <option value="0">Bitte auswählen:?</option>
                        <option value="tbl_geruest">Leihgebühren Gerüst</option>
                        <option value="tbl_geraete">Leihgebühren Geräte</option>
                    </select>
                </td>
            </tr>
        </table>
    </form>