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 4 of 4

Thread: Help with Variables and making them work :/

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

    Default Help with Variables and making them work :/

    <div id="ads">
    <script type="text/javascript">
    var rNumber = randInt(5); // generate a random interger from 1 to 5
    var rAd = adDescription(rNumber); //description of the random ad
    var rlink = adLink(rNumber); //URL of the random ad
    document.write("<a href="rLink">");
    document.write("<img scr="ad + rNumber + .jpg" alt="rAd"/>");
    document.write("<a/>");

    </script>
    </div>

    I am doing my homework for my class and i followed the instruction to the letter.

    The script is supposed to randomly generate 1 out of 5 different images and post them to the web page. Honestly im very stumped as nothing is happening at all.

    Any suggestions? or obvious mistakes in the code?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with Variables and making them work :/

    This is a java forum. Try a javascript forum for better help

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Help with Variables and making them work :/

    Quote Originally Posted by layzer View Post
    <div id="ads">
    <script type="text/javascript">
    var rNumber = randInt(5); // generate a random interger from 1 to 5
    var rAd = adDescription(rNumber); //description of the random ad
    var rlink = adLink(rNumber); //URL of the random ad
    document.write("<a href="rLink">");
    document.write("<img scr="ad + rNumber + .jpg" alt="rAd"/>");
    document.write("<a/>");

    </script>
    </div>

    I am doing my homework for my class and i followed the instruction to the letter.

    The script is supposed to randomly generate 1 out of 5 different images and post them to the web page. Honestly im very stumped as nothing is happening at all.

    Any suggestions? or obvious mistakes in the code?
    Be more precise and get precise answer. Your code has no meaning to us. We don't read minds though. Also, Java!=Javascript. Plus may be some more information about your code could let us help you solving problem.

  4. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Help with Variables and making them work :/

    Please take head of what has been said above.

    Also look at the double quotes in this string and tell me when you are inside a string and when you are not.

    document.write("<img scr="ad + rNumber + .jpg" alt="rAd"/>");

Similar Threads

  1. Instance Variables and local variables difference
    By dcwang3 in forum Java Theory & Questions
    Replies: 3
    Last Post: October 31st, 2011, 06:33 AM
  2. Initializing Variables
    By Tjstretch in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: October 29th, 2011, 12:37 PM
  3. Help with Average and Variables Please =)
    By Raymond Pittman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 9th, 2011, 10:02 AM
  4. Scope of Variables
    By PineAppleKing in forum Java Theory & Questions
    Replies: 5
    Last Post: June 11th, 2011, 10:22 AM
  5. Using variables from different methods?
    By Morevan in forum Object Oriented Programming
    Replies: 3
    Last Post: January 5th, 2010, 07:10 PM