Jump to content
vmars316

Creating Blank page for "document.writeln"

Recommended Posts

Greetings;In the following, what causes the js to create a new page, for writing the "document.writeln" onto: 31: document.writeln("Price: $" + total_price + "<br>");....Thanks...vmars316---START--1: <html>2: 3: <head>4: <title>JS input example.</title>5: <script language="JavaScript">6: <!--7: /* Start of round_total function.8: */9: function round_total © {10: var pennies = c * 100;11: pennies = Math.round(pennies);12: var strPennies = "" + pennies;13: var len = strPennies.length;14: return parseFloat(strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len));15: }16: // End of round_total function.17: 18: /* Start of generate_page function. */19: function generate_page (form) {20: tax = 0.08;21: delivery_p = 2.99;22: var odate = new Date();23: var qty = form.quantity.value;24: var product_v = new String(form.product.value);25: var total_price = product_v.substr(product_v.indexOf("$") + 1, product_v.length - product_v.indexOf("$"));26: var price_without_tax = round_total(qty * total_price);27: var ttax = round_total(price_without_tax * tax);28: var delivery = round_total(qty * delivery_p);29: var total_p = round_total(price_without_tax + ttax + delivery);30: document.writeln("Quantity: " + qty + "<br>");31: document.writeln("Price: $" + total_price + "<br>");32: document.writeln("Tax: $" + ttax + "<br>");33: document.writeln("Delivery: $" + delivery + "<br>");34: document.writeln("Total: $" + total_p + "<br>");35: document.writeln("Order placed on: " + odate.toGMTString());36: }37: // End of generate_page function.38: 39: -->40: </script>41: </head>42: 43: <body>44: 45: <form>46: <p>Product: <select name="product" size="1">47: <option value="Brown Jacket - Size 35 - $58.99">Brown Pants - Size 31 - $58.99</option>48: <option value="Blue Shirt - Size 32 - $69.99">Blue Shirt - Size 32 - $69.99</option>49: </select><br>50: Quantity: <input type="text" name="quantity" size="18" value="1"><br>51: <input type="submit" value="Submit" name="submit" onClick="generate_page(this.form)"><input52: type="reset" value="Reset" name="reset"></p>53: </form>54: </body>55: </html>

Share this post


Link to post
Share on other sites
Look here. The second example comes closest to what you want.
Ah, yes, good aim.Which led me to : http://www.w3schools.com/js/js_ex_dom.asp http://www.w3schools.com/js/js_examples.asp But I am not asking 'how to open a window'. I am saying 'given the code above', (see line 30.) He uses no OPEN , and still he manages to open a window,or at least clear orig window, then writeln to print a receipt. Anyways, Thanks for the link...vmars316 almost forgot, I combine both openWindows into one, in case there are other newbies, like me reading here:<html><!-- http://www.w3schools.com/jsref/met_win_open.asp --><head><script type="text/javascript">function openWin(){myWindow=window.open('','','width=200,height=100');myWindow.document.write("<p>This is 'myWindow'</p>");myWindow.focus();}function open_win() {window.open("http://www.w3schools.com");}</script></head><body><form><input type="button" value="Open little window" onclick="openWin()" /> <input type=button value="Open URL Window" onclick="open_win()" /></form></body></html> Edited by vmars316

Share this post


Link to post
Share on other sites

When called after the page loads, document.write() and document.writeln() automatically clear the page before writing.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...