Results 1 to 3 of 3

Thread: text box

  1. #1

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    text box

    hi,
    Let the computer create a number between 1 and 10 randomly
    and let me try to guess it..(whitout using PROMPT) HOW can I enter a number?how can I use an text field(input-box) to submit my number?..(javascript)
    then I will write..
    if(mynumber==computernumber)
    document.bgColor="blue"...

    can anyone help me...?
    thanks

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Code:
    <form action="#" onsubmit="if(this.txt1.value == computernumber) document.bgColor="blue"; return false;"><p>
      <input name="txt1" />
      <input type="submit" />
    </p></form>
    You could call a function instead of having the code directory in the onsubmit event handler if you want. Do you need the random number code as well?

  3. #3

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    random numbers..

    hi,
    yes I think i need thaat too.
    I would write..

    aaa=Math.floor(Math.random()*10)+1..
    will this do?
    and let's see what u suggest??.....

Posting Permissions

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



Click Here to Expand Forum to Full Width