简体   繁体   中英

change html form value, load page & click button

I am trying to get user input via an html form, update that input via javacript , load a webpage where i will use the updated input to load in. Everything is going well except i can't seem to get that webpages button to click and actually log in with the inputted fields.

EDIT:: To be clear , this page will have a button for user name input. the user inputs his name and clicks the button. I then update that user input and load a new webpage where i will fill a username field and click a button "login".

I have everything working, but i can't seem to click that "login" button on the second webpage. Looking at the webpage i know the class type name and value of the button i need to click

class="btn" type="submit" name="action" value="login"

 <!DOCTYPE html> <html> <head> <script> function func() { var str1 = document.getElementById("name").value; var str2 = "12345"; document.getElementById("name").value = str1.concat(str2); return true; } </script> </head> <body> <form action="website.com" method="POST"> <input name="login" id="name" value="username" /> <button id="button" onclick="func()">press button</button> </form> </body> </html> 

try it

 function func() { var str1 = document.getElementById("name").value; var str2 = "12345"; document.getElementById("name").value = str1.concat(str2); return true; } 
 <form action="website.com" method="POST"> <input name="login" id="name" value="username" /> <button id="button" onclick="func()">press button</button> </form> 

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