Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

javascript - On submit and o'clock not working together

I have read previous posts on this and have tried to apply the onsubmit on my form element in HTML but still doesn't seem to work. I have it as follows:

<form class="button" id="arrow" onsubmit='return hotelList()'>
  <input type='submit' value='Submit'/>
</form>

and js:

const hotelList = () => window.location.href = './ochome.html';

Any suggestions? Thank you


Full code: New Question: my required field does not seem to be working, and the sends me to the other page regardless....

enter code here 

<form action="/user-details.html" class='login'>
            <!-- is this GET or POST?? -->
            <label for="username" >Username</label><br>
            <input class="whitebox" type="text" id='username' required/>
            <label for="pass" id='pass'>Password</label><br>
             <input class="whitebox" type='password' id='passBox' required/>
            <input type="submit" id='arrow' value="> Submit">
          </form>
question from:https://stackoverflow.com/questions/65935491/on-submit-and-oclock-not-working-together

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

the form contains all the input you want to submit and the action is like: action="/file.js" and it has to be a file which handles the data

the code:

<form action="/user-details.html">
      <label for="fname">First name:</label><br>
      <input class="whitebox" type="text" id='username' required/>
      <label for="lname">Last name:</label><br>
       <input class="whitebox" type='password' id='passBox' required/>
      <input type="submit" value="Submit"/>
    </form>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...