1

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é

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
AsRe
  • 11
  • 2
  • This is an extremely strange approach. If you're redirecting, why not make it a regular form submission? There seems to be no need to involve Javascript to achieve what you want. – El_Vanja Jan 08 '21 at 20:09
  • I know, but I just wanted to avoid a "send" button, as mentioned until "now" (I didn't use this script for a while), it worked fine, when I changed the option in my dropdown - it automatically updated with javascript... – AsRe Jan 09 '21 at 06:17
  • anyone has a suggestion? – AsRe Jan 11 '21 at 14:34
  • I don't know how it worked to begin with. Have you tried opening the browser's console and see the error? – El_Vanja Jan 11 '21 at 14:59
  • Anyways, just check out this highly popular question about [redirecting to another page in Javascript](https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage). – El_Vanja Jan 11 '21 at 15:07

1 Answers1

0

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>
AsRe
  • 11
  • 2