www.webdeveloper.com
Results 1 to 3 of 3

Thread: JAVASCRIPT Loadform()

  1. #1
    Join Date
    Dec 2013
    Posts
    7

    JAVASCRIPT Loadform()

    I been working on this problem for two days and have gotten no where. Tried tutorial on http://www.w3schools.com/jsref/met_html_focus.asp to no avail. If anyone can guide me in the right direction. Problem then code below:
    Within the <script> tags create a function named loadform() that displays current date in the form date field and then moves the cursor focus to the qtyl field and selects it. Hint - apply both the focus () and select methods to the qtyl input field. Run the loadform function when the page is loaded.

    <code>
    <html>
    <head>
    <title>GPS-ware Order Form Second Draft</title>
    <style>
    body {background-image: url(border.jpg); background-position:left;
    background-repeat: repeat-y; margin-top:0; padding-top:0}
    #logo {border-bottom-style: solid;
    border-bottom-width:2px;
    border-bottom-color:rgb(223,125,76)}
    #links {color:green; font-family:Arial, Helvetica, sans-serif; font-size:8pt}
    #links a {color:black; text-decoration:none}
    #links a:hover {color:black; text-decoration:underline}
    #prodtable {margin:10px};
    td {font-size:8pt; font-family: Arial, Helvetica, sans-serif}
    .numbers,.date {text-align:right; background-color:lightyellow}
    .quantity {text-align:right}
    .fmlabel {color:brown}
    </style>
    <script type="text/javascript" src="autofillSelect.js"></script>
    <script>
    function dollars(n) {
    n=eval(n);
    n=Math.round(n*100)/100;
    return (n == Math.round(n)) ? n += ".00" : (n*10 == Math.round(n*10)) ? n +="0" : n;
    }

    function todaytxt() {
    var Today=new Date("October, 11, 2004");
    return Today.getMonth()+1+"/"+Today.getDate()+"/"+Today.getFullYear();
    }
    function loadform() {

    </script>
    </head>

    <body>
    <table width="620" cellpadding="0" cellspacing="5">
    <tr>

    <!-- LIST OF LINKS -->
    <td id="links" valign="top" width="100" rowspan="7">
    <h2>Links</h2>
    <a href="#">Home Page</a><br>
    <a href="#">Product Catalog</a><br>
    <a href="#">Order Form</a><br>
    <a href="#">Maps Online</a><br>
    <a href="#">Contact Us</a><br><br>
    <a href="#">Countries</a><br>
    <a href="#">States</a><br>
    <a href="#">National Parks</a><br>
    <a href="#">Hiking Trails</a><br>
    <a href="#">Cities</a><br>
    <a href="#">Astronomical</a><br>
    <a href="#">Natural</a><br><br>
    <a href="#">GoMap 1.0</a><br>
    <a href="#">Drive Planner 2.0<br>
    <a href="#">Hiker 1.0</a><br>
    <a href="#">G-Receiver I</a><br>
    <a href="#">G-Receiver II</a><br>
    <a href="#">G-Receiver III</a><br><br>
    <a href="#">Downloads</a><br>
    <a href="#">Tech Support</a><br>
    <a href="#">FAQs</a>
    </td>

    <!-- GPS-WARE COMPANY LOGO -->
    <td id="logo" valign="top" width="520" colspan="2">
    <img src="gpsware.jpg" alt="GPS-ware">
    </td>
    </tr>

    <tr>

    <!-- START OF ORDER FORM -->
    <form name="order" method="post">
    <td>
    <h1 style="margin-bottom:0px">Order Form</h1>
    </td>

    <!-- FORM DATE -->
    <td align="right">
    <input id="date" name="date" />
    <script type="text/javascript">
    document.getElementById("date").value = new Date();
    </script>


    </td>
    </tr>

    <tr>
    <!-- PRODUCT FIELDS -->
    <td valign="top" colspan="2">
    <fieldset>
    <legend>Enter the quantity of each product and press the Tab key</legend>
    <table border id="prodtable" cellpadding="5">
    <tr>
    <th width="200">Product</th>
    <th>Price</th>
    <th>Quantity</th>
    <th>Cost</th>
    </tr>
    <tr>
    <td>GoMap 1.0</td>
    <td><input class="numbers" name="price1" size="7" value="19.95" disabled></td>
    <td><input class="quantity" name="qty1" size="7"></td>
    <td><input class="numbers" name="sub1" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <td>Drive Planner 2.0</td>
    <td><input class="numbers" name="price2" size="7" value="29.95" disabled></td>
    <td><input class="quantity" name="qty2" size="7" value="0"></td>
    <td><input class="numbers" name="sub2" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <td>Hiker 1.0</td>
    <td><input class="numbers" name="price3" size="7" value="29.95" disabled></td>
    <td><input class="quantity" name="qty3" size="7" value="0"></td>
    <td><input class="numbers" name="sub3" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <td>G-Receiver I</td>
    <td><input class="numbers" name="price4" size="7" value="149.50" disabled></td>
    <td><input class="quantity" name="qty4" size="7" value="0"></td>
    <td><input class="numbers" name="sub4" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <td>G-Receiver II</td>
    <td><input class="numbers" name="price5" size="7" value="199.50" disabled></td>
    <td><input class="quantity" name="qty5" size="7" value="0"></td>
    <td><input class="numbers" name="sub5" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <td>G-Receiver III</td>
    <td><input class="numbers" name="price6" size="7" value="249.50" disabled></td>
    <td><input class="quantity" name="qty6" size="7" value="0"></td>
    <td><input class="numbers" name="sub6" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <td colspan="3" align="right"><span class="fmlabel">Sales Tax:</span>
    </td>
    <td><input class="numbers" name="sub7" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <td colspan="3" align="right"><span class="fmlabel">Shipping:</span>
    <select name="shipping">
    <option value="0">Select a Shipping Method
    <option value="7.95">3-5 days ($7.95)
    <option value="9.95">2 days ($9.95)
    <option value="12.95">Next Day ($12.95)
    </select>
    </td>
    <td><input class="numbers" name="sub8" size="7" value="0.00" disabled></td>
    </tr>
    <tr>
    <th colspan="3" align="right" bgcolor="pink">TOTAL</th>
    <td bgcolor="pink"><input class="numbers" name="total" size="7" value="0.00" disabled></td>
    </tr>
    </table>
    </td>
    </tr>

    <tr>
    <!-- SHIPPING ADDRESS FIELDS -->
    <td valign="top" colspan="2">
    <fieldset>
    <legend>Shipping Address</legend>
    <table>
    <tr>
    <td><span class="fmlabel">E-mail:</span></td>
    <td>
    <input name="email" size="40">
    </td>
    </tr>
    <tr>
    <td><span class="fmlabel">Name:</span></td>
    <td>
    <input name="name" size="40">
    </td>
    </tr>
    <tr>
    <td width="70" valign="top"><span class="fmlabel">Street:</span></td>
    <td>
    <textarea rows="3" cols="40" name="street"></textarea>
    </td>
    </tr>
    <tr>
    <td width="70" valign="top"><span class="fmlabel">City:</span></td>
    <td>
    <input size="30" name="city">
    <span class="fmlabel">State:</span>
    <select name="state">
    <option>AL<option>AK<option>AZ<option>AR<option>CA<option>CO<option>CT<option>DE<option>DC
    <option>FL<option>GA<option>HI<option>ID<option>IL<option>IN<option>IA<option>KS<option>KY
    <option>LA<option>ME<option>MD<option>MA<option>MI<option>MN<option>MS<option>MO<option>MT
    <option>NE<option>NV<option>NH<option>NJ<option>NM<option>NY<option>NC<option>ND<option>OH
    <option>OK<option>OR<option>PA<option>RI<option>SC<option>SD<option>TN<option>TX<option>UT
    <option>VT<option>VA<option>WA<option>WV<option>WI<option>WY
    </select>
    <span class="fmlabel">ZIP:</span>
    <input size="10" name="zip">
    </td>
    </tr>
    </table>
    </fieldset>
    </td>
    </tr>

    <tr>
    <!-- CREDIT CARD FIELDS -->
    <td valign="top" colspan="2">
    <fieldset>
    <legend>Credit Card Information</legend>
    <table width="100%">
    <tr>

    <!-- CARD TYPE -->
    <td width="70" valign="top"><span class="fmlabel">Card:</span></td>
    <td colspan="3">
    <select name="ccard">
    <option value="">Select a Credit Card
    <option value="ae">American Express
    <option value="cc">CitiBank
    <option value="dn">Diner's Club
    <option value="di">Discover
    <option value="mc">MasterCard
    <option value="vi">Visa
    </select>
    </td>
    </tr>
    <tr>

    <!-- NAME ON CARD -->
    <td width="70" valign="top"><span class="fmlabel">Name:</span></td>
    <td colspan="3">
    <input size="40" name="cname">
    </td>
    </tr>

    <tr>

    <!-- CARD NUMBER -->
    <td width="70" valign="top"><span class="fmlabel">Number:</span></td>

    <!-- CARD EXPIRATION DATE -->
    <td colspan="3">
    <input type="password" size="20" name="cnumber">
    <span class="fmlabel">Expiration:</span>
    <select name="expmonth">
    <option>01<option>02<option>03<option>04<option>05<option>06
    <option>07<option>08<option>09<option>10<option>11<option>12
    </select>
    /
    <select name="expyear">
    <option>2004<option>2005<option>2006<option>2007
    <option>2008<option>2009<option>2010
    </select>
    </td>
    </tr>
    </table>
    </fieldset>
    </td>
    </tr>

    <tr>

    <!-- BUTTONS TO SUBMIT OR CANCEL THE ORDER -->
    <td align="center" colspan="2">
    <input type="submit" value="Submit Order">
    &nbsp;&nbsp;
    </td>
    </tr>

    </form>

    </table>
    </body>
    </html>


    <form name="dform">
    <input type="text" name="currentdate" size=11>
    </form>
    </code>

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    may be this is because there is no qtyl input field in your code?

    p.s. the <code></code> tags usually look like [code][/code]

  3. #3
    Join Date
    Oct 2013
    Posts
    609
    Perhaps it should be qty1?

    Code:
    <input class="quantity" name="qty1" size="7">

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



Recent Articles