Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: javascript problem

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up javascript problem

    <script>
    function show1()
    {
    var randomnumber=Math.floor(Math.random()*21);
    var randomnumber1=Math.floor(Math.random()*31);
    var randomnumber2=Math.floor(Math.random()*41);
    var randomnumber3=Math.floor(Math.random()*51);
    var randomnumber4=Math.floor(Math.random()*101);
    document.form1.text4.value=randomnumber3;
    document.form1.text3.value=randomnumber2;
    document.form1.text2.value=randomnumber1;
    document.form1.text1.value=randomnumber;
    document.form1.text5.value=randomnumber4;
    document.form1.text1.focus();

    }
    </script>
    //calling on buttons of form to store values in text box (text1,text2,text3,text4,text5)

    problem is that when i am calling above function on buttons it shows result in textbox but value autometically get refreshed.

    can any one help me????????????????????????


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: javascript problem

    Hello kundan_101,

    This is a JAVA forum, not a JAVASCRIPT forum. They are 2 different languages.

    I suggest you try - javascript forum - Google Search

    When you say "it shows result in textbox but value autometically get refreshed." Do you want it to append the numbers into the textbox each time?

    I'm not sure if something like this will work?!

    document.form1.text1.value = document.form1.text1 + randomnumber;
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. The Following User Says Thank You to JavaPF For This Useful Post:

    kundan_101 (December 30th, 2010)

  4. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: javascript problem

    thanks for reply!!!!!!!!!!!!!!

Similar Threads

  1. Can I ask questions here about javascript on my website?
    By bateman in forum Member Introductions
    Replies: 2
    Last Post: November 5th, 2010, 11:30 AM
  2. Javascript/JQuery question
    By Charlie in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 5th, 2010, 09:39 AM
  3. Javascript Bubble Sort
    By Fidelacchius in forum What's Wrong With My Code?
    Replies: 17
    Last Post: May 24th, 2010, 04:43 PM
  4. calendar javascript required
    By sagar13 in forum Paid Java Projects
    Replies: 0
    Last Post: February 4th, 2010, 11:57 PM
  5. How can i put session in Javascript?
    By rajani in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: July 8th, 2009, 12:46 PM