Log in

View Full Version : Login form with radio buttons



HTMHELL
11-08-2006, 07:19 PM
Hello all, i have been looking around allday and havent found anything that remotely helps. I know [B]some[B] html but only the basic stuff.

What i am trying to do is have a login form which 2 radio buttons beneath it... one for admin and one for demo. Simply click the admin and the values in the login form are set to admin user and password, or click the demo and the values are set for demo login.

This seems easy enough to do, i know how to create a login form, just not how to impliment it to work with this.

can anyone help or advise me??

Thanks

Twey
11-08-2006, 09:03 PM
<head>
<!-- ... -->
<style type="text/css">
form.blockLabels label {
display: block;
}
</style>
<script type="text/javascript">
var loginValues = {
'admin' : "adminPassword",
'demo' : "demoPassword"
};

function setValues(id) {
var f = this.elements;
if(loginValues[id]) {
f['user'].value = id;
f['pass'].value = loginValues[id];
}
}
</script>
</head>

<!-- ... -->

<form action="loginpage.psp" class="blockLabels">
<label>
<input type="checkbox" onclick="setValues.call(this.form, 'admin');">
Admin
</label>
<label>
<input type="checkbox" onclick="setValues.call(this.form, 'demo');">
Demo
</label>
<label>
Username:
<input type="text" name="user">
</label>
<label>
Password:
<input type="password" name="pass">
</label>
</form>Note that this requires Javascript and will not be available to users without Javascript support. I must wonder, also, what purpose this is intended to serve.