Hi all - new to javascript and am having an issue that I have searched all over Google for and can't find my answer...
Working on a project that adds coins and displays them...That all works fine, but when I go to display them, the images are being displayed on a new page...I want them displayed on the same page...
Here is my code:
Any images can be used as long as they are named correctly and here is the CSS file:Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Coin Count</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Coin Count"> <meta name="keywords" content="javascript, mouseover, html, css, php, ajax"> <link rel="stylesheet" href="testhome1.css" type="text/css"> <script type="text/javascript"> <!-- var rad_val, ind, val, cointot, result, picture function coinCalculate() { for (var i=0; i < document.frmCoinCounter.rbType.length; i++) { if (document.frmCoinCounter.rbType[i].checked) { var rad_val = document.frmCoinCounter.rbType[i].value; } } ind = document.frmCoinCounter.numberCoins.selectedIndex; val = document.frmCoinCounter.numberCoins.options[ind].value; cointot = rad_val * val; document.frmCoinCounter.result.value = "$" + cointot; if (rad_val==.25) picture="quarter.gif"; else if (rad_val==.10) picture="dime.gif"; else if (rad_val==.05) picture="nickel.gif"; else picture="penny.gif"; for (i=0;i<val;i++) { document.write('<img border="0" src="' + picture + '">'); } } //--> </script> </head> <body> <h2><center>Coin Counter</center></h2> <form name="frmCoinCounter"> <h3>Choose the denomination of coin to calculate</h3> <h2><input type="radio" name="rbType" id="rbQuarters" value=".25">Quarters<br /> <input type="radio" name="rbType" id="rbDimes" value=".10">Dimes<br /> <input type="radio" name="rbType" id="rbNickels" value=".05">Nickels<br /> <input type="radio" name="rbType" id="rbPennies" value=".01">Pennies<br / > <h3>Select number of coins to calculate:</h3> <select name="numberCoins"> <option value="">Select A Number...</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></h3> <input type="button" id="btnCalc" name="btnCalc" onClick="coinCalculate()" value="Calculate Coins" /> <br /><br /> <input type = "text" name = "result" size = 10 value = "$0.00"> <br /> <br /> <input type = "reset"> <br /> <br /> </form> </body> </html>
And assistance/direction would be greatly appreciated...Code:/* Layout Stylesheet */ body { margin:5px; background: green; color: yellow; text-align:center; padding:5px; } li { color: black; font-size: 1.1em; text-align: left;} p { color: blue; font-size: 1.1em; text-align: justify; padding:10px;} h1, h2, h3, h4, h5, p { font-family: Comic Sans MS, Arial, Geneva, Helvetica, sans-serif;} h1 { color: black; } h2 { color: yellow; } h3 { color: black; } h4 { color: black; } h5 { color: black; } a:link { color: blue; } a:visited { color: #996699; } a:hover { color: red; } a:active { color: blue; } .content {background:green;color:white;}
I did meess around with the getElementByID vice the document.write and got error messages stating that the method was invalid for this???
Thanks In Advance...



Reply With Quote


Bookmarks