Jump to content

[SOLVED] Can't navigate page with button's click event


colap

Recommended Posts

        <script type="text/javascript" language="javascript">
            function thatpage(){
                document.URL="byte.html";
            }
        </script>

        <form>
            <input name="ins" type="submit"  value="INSERT" onclick="thatpage"/>
            <input name="upt" type="submit" value="UPDATE"/>
            <input name="del" type="submit" value="DELETE"/>
        </form>

        <script type="text/javascript" language="javascript">
            function thatpage(){
                document.location="byte.html";
            }
        </script>

        <form>
            <input name="ins" type="button"  value="INSERT" onclick="thatpage()"/>
            <input name="upt" type="submit" value="UPDATE"/>
            <input name="del" type="submit" value="DELETE"/>
        </form>

 

document.URL is readonly propery. You can't change it.

HTML button type 'submit' will always try to send the form. Use type 'button' for other actions

Calling JS function you have to add () to function identifier.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.