Results 1 to 2 of 2

Thread: Login form with radio buttons

  1. #1
    Join Date
    Nov 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Login form with radio buttons

    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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •