Results 1 to 1 of 1

Thread: Java banner help, newbie

  1. #1
    Join Date
    Feb 2011

    Java banner help, newbie

    Hello everyone. I am new to the java language. I am currently trying to complete a school assignment that I can not figure out. No I am not trying to have you guys do my work for me. I have been trying everything I can think of but to no avail. Below is a copy of my code so far, along with the external files. Everything works, except what is inside the "ads" div tag. I am trying to use the "rNumber" variable to create random banner line up. At the end of my script I need to put in (The () are just to show variables, and should not be in the final code) <a href="(rLink)"> <img src="ad(rNumber).jpeg" alt="(rAd)"/></a>

    Thank you all for any help you can give me. If I left out any necessary information please just let me know
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="http://www.w3.org/1999/xhtml">
       New Perspectives on JavaScript, 2nd Edition
       Tutorial 1
       Case Problem 2
       The Ridgewood Herald Tribune
       Author: Scott Shannon
       Date: 1/26/11
       Filename:         front.htm
       Supporting files: ads1.jpg - ads5.jpg, ads.js, fp.jpg, front.htm, logo.jpg, random.js, 
       <title>The Ridgewood Herald Tribune</title>
       <link href="styles.css" rel="stylesheet" type="text/css" />
       <script src="random.js" type="text/javascript"></script>
       <script src="ads.js" type="text/javascript"></script>
    <div id="links">
      <p class="section">Main</p>
      <p class="linksub">
         <a href="#">Home</a><br />
         <a href="#">Subscriptions</a><br />
         <a href="#">Contact Us</a><br />
         <a href="#">News Sources</a><br /><br />
      <p class="section">News</p>
      <p class="linksub">
        <a href="#">Local</a><br />
        <a href="#">National</a><br />
        <a href="#">International</a><br />
      <p class="section">Sports</p>
      <p class="linksub">
        <a href="#">Baseball</a><br />
        <a href="#">Basketball</a><br />
        <a href="#">Football</a><br />
        <a href="#">Golf</a><br />
        <a href="#">Hockey</a><br />
        <a href="#">Miscellaneous</a><br />
      <p class="section">Opinion</p>
      <p class="linksub">
        <a href="#">Editorials</a><br />
        <a href="#">Columnists</a><br />
        <a href="#">Letters</a><br />
      <p class="section">Classifieds</p>
      <p class="linksub">
        <a href="#">Employment</a><br />
        <a href="#">For Sale</a><br />
        <a href="#">Personals</a><br />
        <a href="#">Real Estate</a><br />
        <a href="#">Wanted</a><br />
      <p class="section">Other</p>
      <p class="linksub">
        <a href="#">Business</a><br />
        <a href="#">Weather</a><br />
        <a href="#">Entertainment</a>
    <div id="main">
       <div id="ads">
             var rNumber = randInt(5);
             var rAd = adDescription(rNumber);
             var rLink = adLink(rNumber);
             document.write("<a href = rLink >");
             document.write("<img src = "ad"rNumber.jpg alt = rAd/>
      <div id="request"><a href="#">Contact us today to place your ad</a></div>
      <p id="logo"> 
         <img src="logo.jpg" alt="Ridgewood Herald Tribune" />
      <p id="fp">
      <img src="fp.jpg" alt="" />
      <h2>Park Opens</h2>
      <p id="intro">The <i>Adventure Island</i> theme park opened its doors on 
      Monday near Ridgewood. The park, one of the biggest in New Jersey, drew
      large crowds, but the long lines didn't deter anyone. "I've been watching
      them put up the rides over the last year, it's really exciting to finally
      get inside the gates!" said Ridgewood resident, Denise Brooks.</p>
      <p class="cont"><a href="#">story continues on page 2...</a></p>
      <address id="footer">
      <b>Ridgewood Herald Tribune</b> &nbsp;&#176;&nbsp; 10010 Atwood Ave. 
      &nbsp;&#176;&nbsp; Ridgewood, NJ &nbsp; &nbsp; 07451<br />
      Phone: (201)555-1101 &nbsp;&#176;&nbsp; Fax: (201)555-1102
    External Java. Title = ads.js
       New Perspectives on JavaScript, 2nd Edition
       Tutorial 1
       Case Problem 2
       Function List:
          Used to return a description for ad "n"
          Used to return the URL for ad "n"
    function adDescription(n) {
       var descrip = new Array();
       descrip[1]="[AD] Diamond Health Club - For all your Health Club Needs";
       descrip[2]="[AD] Pixal - Quality Digital Equipment and Accessories";
       descrip[3]="[AD] dHome - Quality Geodesic Domes and Homes";
       descrip[4]="[AD] Dunston Retreat Center - get away";
       descrip[5]="[AD] LanGear - Quality Network Solutions for all your Business Needs";
       return descrip[n];
    function adLink(n) {
       var link = new Array();
       return link[n];
    External Java. Title = random.js
       New Perspectives on JavaScript, 2nd Edition
       Tutorial 1
       Case Problem 2
       Function List:
          Used to return a random integer from 1 to 'n'
    function randInt(n) {
       randNum = Math.ceil(Math.random()*n);
       return randNum;
    Again. Thanks for any help.
    Last edited by Kor; 02-04-2011 at 04:59 AM. Reason: wrap the code [code][/code]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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