简体   繁体   中英

Passing variable to a form action script

I'm new with javascript, can someon please point me in the right direction to accomplish the following code ?

I have a page to automatically log me in into websites for work, but i'm searching a way to have the login credentials being either read from a ini file, or just by using document.write so its easer to pass and change these credentials in my HTML that hase a lot of these buttons.

<script language="javascript">


var username = "firstusername";
var password = "firstpassword";


<!-- link -->
<form action="***************" method="post"  target="_blank">
<p>
<input type="hidden" name="HdnCallingProgram" value="login"/>
<input type="hidden" name="HdnAction" value="Login"/>
<input type="hidden" name="txtUserId" value="document.write(username)"/>
<input type="hidden" name="txtPassword" value="document.write(password)"/>
<input type="hidden" name="chkRemember" value="1"/>
<a class="button1" title="Bij fout aanmelden : gebruik browser back button en terug op knop klikken"  onclick="parentNode.parentNode.submit()">Cafe</a>
</p>
</form>


</script>

Thanks for reading this!

<form action="***************" method="post"  target="_blank">
    <p>
        <input type="hidden" name="HdnCallingProgram" value="login"/>
        <input type="hidden" name="HdnAction" value="Login"/>
        <input type="hidden" id="txtUserId" name="txtUserId" value=""/>
        <input type="hidden" id="txtPassword" name="txtPassword" value=""/>
        <input type="hidden" name="chkRemember" value="1"/>
        <a class="button1" title="Bij fout aanmelden : gebruik browser back button en terug op knop klikken"  onclick="this.parentNode.parentNode.submit()">Cafe</a>
    </p>
</form>

<script type="text/javascript">
var username = "firstusername";
var password = "firstpassword";

document.getElementById('txtUserId').value = username;
document.getElementById('txtPassword').value = password;
</script>

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