Shuubaru Posted August 15, 2017 Share Posted August 15, 2017 Hello, I'm having some problems with this functions as I'm not familiar with javascript, I'm working with a HTML login which is almost done except for one thing, the user data saving. I've seen some "examples" about the use of javascript in login panels and follow the examples didn't work in any way. I just want to load the username and password from some xml and then autofilling them on the login panel, like this: This is what I tried: HTML <form action="javascript:loginTrigger()" method="post"> <input id="UsernameInput" type="text" class="username" placeholder="Username"> <input id="PasswordInput" type="password" class="password" placeholder="Password"> <button type="submit" class="log_button">Login</button> <div class="error"><span style="color:#999">+</span></div> </form> LUA username = magicalFunctionThatLoadTheUsername() password = magicalFunctionThatLoadThePassword() executeBrowserJavascript(theBrowser, 'document.getElementById("UsernameInput").val = "'..username..'";') executeBrowserJavascript(theBrowser, 'document.getElementById("PasswordInput").val = "'..password..'";') I'm not experienced with javascript (as you can obviously see) but I don't really get why it does not work as I'm follow the same steps as other examples I've seen around the web. Link to comment
anchor Posted August 15, 2017 Share Posted August 15, 2017 (edited) object.value = "text"; //setter object.value; //getter learn more about html dom and js > https://www.w3schools.com/jsref/prop_text_value.asp Edited August 15, 2017 by anchor Link to comment
Shuubaru Posted August 15, 2017 Author Share Posted August 15, 2017 (edited) 3 hours ago, anchor said: object.value = "text"; //setter object.value; //getter learn more about html dom and js > https://www.w3schools.com/jsref/prop_text_value.asp Well, it's seems the problem was that executeBrowserJavascript function was called first, before that the page itself were loaded... I've used a timer to call that function in 2 seconds and now it does work in the way I want: setTimer(executeBrowserJavascript,2000,1,theBrowser, "document.getElementById('UsernameInput').value = '"..username.."';") setTimer(executeBrowserJavascript,2000,1,theBrowser, "document.getElementById('PasswordInput').value = '"..password.."';") Edited August 15, 2017 by Shuuichi Link to comment
Administrators Lpsd Posted August 15, 2017 Administrators Share Posted August 15, 2017 I think isBrowserLoading would be better than a timer Link to comment
Tails Posted August 15, 2017 Share Posted August 15, 2017 You should use OnClientBrowserDocumentReady 1 Link to comment
Shuubaru Posted August 16, 2017 Author Share Posted August 16, 2017 21 hours ago, Tails said: You should use OnClientBrowserDocumentReady Thanks, it does work better with this function. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now