SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Random number & text generator.

    hi all im trying to put together a random number generator. it's working fine but i want to be able to have a name field that when filled in it will be the start of the random number. here's what i have so fare.

    <script>

    var keylist="abcdefghijklmnopqrstuvwxyz123456789"
    var temp=''

    function generatepass(plength){
    temp=''
    for (i=0;i<plength;i++)
    temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
    return temp
    }

    function populateform(enterlength){
    document.pgenerate.output.value=generatepass(enterlength)
    }
    </script>

    <form name="pgenerate">
    <input name="output" type="text" onFocus="populateform(this.form.thelength.value)" size=18 readonly="">
    <input type="hidden" name="thelength" size=3 value="10">
    <input type="text" name="name">

    </form>

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Replace your html code to following:
    Code:
    <form name="pgenerate">
    <input name="output" type="text" onFocus="populateform(this.form.thelength.value)" size=18 readonly="">
    <input type="hidden" name="thelength" size=3 value="10">
    <input type="text" name="name" onBlur="javascript: this.form.output.value=this.value+this.form.output.value">
    </form>
    PHP Functions Class/Php Stuff: php-classes-functions.blogspot.com
    SMS World: sms-treasure.blogspot.com
    Finance Business India: financebusinessindia.blogspot.com
    Retail Market India: retailmarketindia.blogspot.com


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
  •