简体   繁体   中英

How do I run a js function and change html page?

tl;dr - Is it possible to have a submit button run a function and change from it's current HTML page to another while using the result of the function on the page it switches to?

Currently I have it running a function but now I have a second function added to the js file. To display the result I want to change HTML page.

This is the current form I have atm:

<form onsubmit="return rrr()" method ="POST">
   What room is closest to you: <input id="from" type="text">
   <br>
   <br>
    What room do you want to go to : <input id="to" type="text">
   <br>
   <br>
   <input type="submit">
</form>

That works fine at the moment. Want I'm trying to do is, when I press submit, it runs the rrr() function and change to another HTML page where I can run the other function which is where the result for the functions will be displayed.

function rrr(){
    window.location.href = 'https://stackoverflow.com/help/how-to-ask'
}

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