473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

€ before my number

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
2 1024
epots9
1,351 Expert 1GB
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
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

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

Similar topics

3
by: Shay Hurley | last post by:
this is probably a stupid question so apologies in advance. I am trying to format a number to look like a phone number with "-"'s between the numbers etc e.g. 15554256987 should be formatted as...
8
by: EAS | last post by:
Hey, I'm new to python (and programming in general) so I'll prolly be around here a lot... Anyways, I've found out how to make a "guess my number game" where the player guesses a number between...
11
by: don | last post by:
Ok, this is a homework assignment, but can you help me out anyway...... I need a routine for figuring out if a number inputted by the user is a prime number or not...... all I'm asking for is Not...
27
by: Gaijinco | last post by:
Sooner or later everytime I found recreational programming challenges I stumble with how I test if a number is has decimal places differnt than 0? For example if I want to know if a number is a...
13
by: Ron | last post by:
Hi all I'm deciding whether to use the PK also as an account number, invoice number, transaction number, etc that the user will see for the respective files. I understand that sometimes a...
19
by: gk245 | last post by:
Trying to write a program that will figure out if a number is perfect or not. Here is my logic: 1) Read in the number 2) Split it up (number - 1) 3) Put all the split up numbers into an...
4
by: SweetLeftFoot | last post by:
Hello, i have designed some code that works out the first 250 prime numbers and prints them to the screen. However i need to implement 2 functions, one of which returns a 1 if the number is a prime...
4
by: fatimahtaher | last post by:
Hi, I am supposed to create a program that generates a random number and then asks the user to guess the number (1-100). The program tells the user if he guessed too high or too low. If he...
5
by: silversnake | last post by:
I'm trying to write a program that take a input number and prints if is a prime numbers but is not working for instance, it says that 4 is prime while 5 is not. can anyone see what the problem is ....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.