SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    griffith
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Generate Random number and input into form field

    This is my first stab at javascript...I need to generate a random, non-repeating number that increases by +1 each time a form is accessed. Plus, I need to display that random number into one of the form fields. I am completely lost...I can find random number generators, but I do not know enough to tweak them for my needs. Any help is greatly appreciated.

  2. #2
    SitePoint Guru gavwvin's Avatar
    Join Date
    Nov 2004
    Location
    Cornwall, UK
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if I've understood you correctly..., but you can have a "random, non-repeating number that increases by +1"- its not random! Do you mean the first load is random , then increases each time afterwards? I don't think theres anyway of getting javascript to count howmay time a page is loaded, it can't "remember" anything across pages, you would need something server-side for that.

    to display a javascript variable in a form field you just put:
    <input type="text" id="input" />
    <script>
    document.getElementById("input").value=variable
    </script>


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
  •