Jump to content

Creating Blank page for "document.writeln"


vmars316

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>

Link to comment
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>
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...