By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

€ before my number

P: 47
i've somehow managed to get a piece of javascript, kicking and screaming to work...... i just need to get a € before my "total amount"

basicly, i've a list of 10 items, the user puts the quantity of each in and the quantity and the price is displayed. this works, but i gotta get that little euro sign in...... it's prob very easy, but my eyes are close to bleeding.... so a little help would be apriciated....... thanks.......

lines 39 and 54



here's the code

Expand|Select|Wrap|Line Numbers
  1.  
  2. <script language="javascript1.2">
  3.  
  4.  
  5. function checkreset()
  6. {
  7.  
  8.    if (confirm('Are you sure you wish to clear the form?'))
  9.    {
  10.       return true
  11.    }
  12.    return false
  13. }
  14.  
  15.  
  16. function addnumbers()
  17. {
  18.  
  19. // This function reads the values from the input boxes
  20. // parseInt converts the input boxes into an integer
  21.  
  22. var x,y,result;
  23. a = parseInt(document.form1.abox.value);
  24. b = parseInt(document.form1.bbox.value);
  25. c = parseInt(document.form1.cbox.value);
  26. d = parseInt(document.form1.dbox.value);
  27. e = parseInt(document.form1.ebox.value);
  28. f = parseInt(document.form1.fbox.value);
  29. g = parseInt(document.form1.gbox.value);
  30. h = parseInt(document.form1.hbox.value);
  31. i = parseInt(document.form1.ibox.value);
  32. j = parseInt(document.form1.jbox.value);
  33.  
  34. // Then we do the math
  35.  
  36. result = a + b + c + d + e + f + g + h + i + j;
  37.  
  38. // And write the result straight to the screen
  39. document.form1.qbox.value = result;
  40. document.form1.totalbox.value = result*10;
  41.  
  42. // As the function has already done the output, we don’t need a return value
  43. }
  44. </script>
  45.  
  46.  

and the html


Expand|Select|Wrap|Line Numbers
  1.  
  2. <body>
  3. <form name="form1" onReset="return checkreset()">
  4.  
  5. <table width="700" border="0" cellpadding="20" cellspacing="1" bgcolor="#FF6600">
  6.   <tr>
  7.     <td><span class="style5">The Unbelievabley Cool T-Shirt Shop </span></td>
  8.   </tr>
  9. </table>
  10. <table width="700" border="0" cellpadding="15" cellspacing="1" bgcolor="#FF6600">
  11.   <tr>
  12.     <td width="65%" bgcolor="#FFFFFF"><img src="images/t1.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2">                  Never Forget: <span class="style4">&euro;10</span> </span><br />
  13.       <br />
  14.       Quantity</span> 
  15.     <input type="text" id="abox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  16.     &nbsp;<span class="style1">Gift Wrap? </span>
  17.     <label>
  18.     <input name="gift" type="checkbox" id="gift" value="checkbox" />
  19.     <br />
  20.     </label></td>
  21.     <td width="35%" rowspan="10" valign="top" bgcolor="#FFFFFF">
  22.  
  23.  
  24.  
  25.     <table width="100%" border="0" cellspacing="1" cellpadding="6">
  26.       <tr>
  27.         <td colspan="3" bgcolor="#FFF7D2"><span class="style3">Please choose your region for shipping </span></td>
  28.         </tr>
  29.       <tr>
  30.         <td align="center"><span class="style1"><strong>Ireland<br />
  31.         </strong>free </span><br />
  32.           <input type="radio" name="delivery" value="0"></td>
  33.         <td align="center"><span class="style1"><strong>Other EU</strong><br />
  34.           &euro;5<br />
  35. </span>
  36.         #  <input type="radio" name="delivery" onclick="getTotal();" value="5">
  37.         #</td>
  38.         <td align="center">&nbsp; <span class="style1"><strong>Rest of World</strong><br />
  39.           &euro;10<br />
  40. </span>
  41.           <input type="radio" name="delivery" onclick="getTotal();" value="10"></td>
  42.       </tr>
  43.     </table>
  44.  
  45.       <table width="100%" border="0" cellspacing="1" cellpadding="6">
  46.         <tr>
  47.           <td colspan="2" bgcolor="#FFF7D2"><span class="style3">Shopping Cart </span></td>
  48.         </tr>
  49.         <tr>
  50.           <td><span class="style1">Quantity</span></td>
  51.           <td><input type="text" id="qbox" value="0"></td>
  52.         </tr>
  53.         <tr>
  54.           <td><span class="style1">Total</span></td>
  55.           <td><input type="text" id="totalbox" value="0"></td>
  56.         </tr>
  57.         <tr>
  58.           <td></td>
  59.           <td align="right"><input type="reset" value="Reset"></td>
  60.         </tr>
  61.       </table> 
  62.  
  63.  
  64.     <br /></td>
  65.   </tr>
  66.   <tr>
  67.     <td bgcolor="#FFFFFF"><img src="images/t2.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2">                   Viva La Evoluci&oacute;n: <span class="style4">&euro;10</span></span></span><span class="style1"><br />
  68.       <br />
  69.       Quantity</span>
  70.        <input type="text" id="bbox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  71. &nbsp;<span class="style1">Gift Wrap? </span>
  72. <label>
  73. <input name="gift2" type="checkbox" id="gift2" value="checkbox" />
  74. </label></td>
  75.   </tr>
  76.   <tr>
  77.     <td bgcolor="#FFFFFF"><img src="images/t3.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2"> Finders Keepers: <span class="style4">&euro;10</span></span></span><span class="style1"><br />
  78.       <br />
  79.       Quantity</span>
  80.        <input type="text" id="cbox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  81. &nbsp;<span class="style1">Gift Wrap? </span>
  82. <label>
  83. <input name="gift22" type="checkbox" id="gift22" value="checkbox" />
  84. </label></td>
  85.   </tr>
  86.   <tr>
  87.     <td bgcolor="#FFFFFF"><img src="images/t4.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2">                   Dont Stop Believin: <span class="style4">&euro;10</span></span></span><br />
  88.       <br /> 
  89.       <span class="style1">Quantity</span>
  90.        <input type="text" id="dbox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  91. &nbsp;<span class="style1">Gift Wrap? </span>
  92. <label>
  93. <input name="gift222" type="checkbox" id="gift222" value="checkbox" />
  94. </label></td>
  95.   </tr>
  96.   <tr>
  97.     <td bgcolor="#FFFFFF"><img src="images/t5.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2"> Greece: <span class="style4">&euro;10</span></span></span><span class="style1"><br />
  98.       <br />
  99.       Quantity</span>
  100.       <input type="text" id="ebox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  101. &nbsp;<span class="style1">Gift Wrap? </span>
  102. <label>
  103. <input name="gift2222" type="checkbox" id="gift2222" value="checkbox" />
  104. </label></td>
  105.   </tr>
  106.   <tr>
  107.     <td bgcolor="#FFFFFF"><img src="images/t6.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2"> South Korea's Got Seoul: <span class="style4">&euro;10</span></span></span><span class="style1"><br />
  108.       <br />
  109.       Quantity</span>
  110.        <input type="text" id="fbox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  111. &nbsp;<span class="style1">Gift Wrap? </span>
  112. <label>
  113. <input name="gift22222" type="checkbox" id="gift22222" value="checkbox" />
  114. </label></td>
  115.   </tr>
  116.   <tr>
  117.     <td bgcolor="#FFFFFF"><img src="images/t7.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2"> Camping Is Intents: <span class="style4">&euro;10</span></span></span><span class="style1"><br />
  118.       <br />
  119.       Quantity</span>
  120.       <input type="text" id="gbox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  121. &nbsp;<span class="style1">Gift Wrap? </span>
  122. <label>
  123. <input name="gift222222" type="checkbox" id="gift222222" value="checkbox" />
  124. </label></td>
  125.   </tr>
  126.   <tr>
  127.     <td bgcolor="#FFFFFF"><img src="images/t8.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2"> You Complete Me: <span class="style4">&euro;10</span></span></span><span class="style1"><br />
  128.       <br />
  129.       Quantity</span>
  130.        <input type="text" id="hbox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  131. &nbsp;<span class="style1">Gift Wrap? </span>
  132. <label>
  133. <input name="gift2222222" type="checkbox" id="gift2222222" value="checkbox" />
  134. </label></td>
  135.   </tr>
  136.   <tr>
  137.     <td bgcolor="#FFFFFF"><img src="images/t9.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2"> Leave Lindsay A-Lohan: <span class="style4">&euro;10</span></span></span><br />
  138.         <br />
  139.       <span class="style1">Quantity</span>
  140.        <input type="text" id="ibox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  141. &nbsp;<span class="style1">Gift Wrap? </span>
  142. <label>
  143. <input name="gift22222222" type="checkbox" id="gift22222222" value="checkbox" />
  144. </label></td>
  145.   </tr>
  146.   <tr>
  147.     <td bgcolor="#FFFFFF"><img src="images/t10.jpg" alt="never forget" width="100" height="75" /> <span class="style1">&nbsp;<span class="style2"> Blimpin' Ain't Easy: <span class="style4">&euro;10</span></span></span><br />
  148.         <br />
  149.       <span class="style1">Quantity</span>
  150.        <input type="text" id="jbox" onChange="addnumbers()" value="0" size="3" maxlength="3">
  151. &nbsp;<span class="style1">Gift Wrap? </span>
  152. <label>
  153. <input name="gift222222222" type="checkbox" id="gift222222222" value="checkbox" />
  154. </label></td>
  155.   </tr>
  156. </table>
  157. </form>
  158. </body>
  159.  
  160.  
  161.  
Oct 26 '07 #1
Share this Question
Share on Google+
2 Replies


epots9
Expert 100+
P: 1,351
try this:

Expand|Select|Wrap|Line Numbers
  1. document.form1.totalbox.value = "&euro;" + result*10;
  2.  
or
Expand|Select|Wrap|Line Numbers
  1. document.form1.totalbox.value = "&amp;#8364;" + result*10;
  2.  
i think both should work, give them a shot and post back how it goes
good luck
Oct 26 '07 #2

P: 47
you the man, that worked a treat.

document.form1.totalbox.value = "€" + result*10.21;

anychance you can work your magic on this one?

http://www.thescripts.com/forum/thread728882.html
Oct 26 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.