简体   繁体   中英

Javascript for url redirection on save

I was wondering what the code might be to have a form redirect you to a website when it is saved.

Java code on the form is:

<script language="JavaScript">
    function saveRadioButton(radioVal, hiddenId)
    {
        var hidden = document.getElementById(hiddenId);
        hidden.value = radioVal;
    }
</script>

Once saved I would like it to send you to x website....

First Java != JavaScript. Two different animals.

For JavaScript it's as simple as

window.location = "http://www.google.com/"

A simple Google search shows this...

http://www.tizag.com/javascriptT/javascriptredirect.php

So assuming you want to submit the value you've just set to hidden :

<form id="myForm" method="GET" act="http://google.com">

Assuming the id of your form is "myForm" and the hidden input element lies inside this form. In JS:

document.getElementById("myForm").submit();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM