473,386 Members | 1,810 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,386 software developers and data experts.

text is displayed then dissapears

tolkienarda
316 100+
hi all

i just wrote a script that calculates some shipping costs for a company and every time the form is submitted the results of my calculations flash on my screen and then vanish. does anyone know how to make the changes permanent. below is the code:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <title>js calculator</title>
  5. <script>
  6. function calculate()
  7. {
  8. var val = document.auto_compatible.quantity.value;
  9. var val2 = document.auto_compatible.type.value;
  10. var vals = val2.split("@");
  11. var final = vals[1] * val;
  12. var full = vals[2] * val;
  13. var savings = vals[3] * val;
  14. document.getElementById("final_auto_compatible").innerHTML= final;
  15. document.getElementById("full_auto_compatible").innerHTML= full;
  16. document.getElementById("savings_auto_compatible").innerHTML= savings;
  17.  
  18. }
  19. </script>
  20. </head>
  21.  
  22. <body>
  23. <table width="800">
  24.     <tr>
  25.         <td width="153">&nbsp;</td>
  26.         <td>Weight</td>
  27.         <td>Quantity</td>
  28.         <td>Final Cost</td>
  29.         <td>Full Rate</td>
  30.         <td>Savings</td>
  31.     </tr>
  32.     <tr>
  33.         <td colspan="6">Auto Compatible Letters</td>
  34.     </tr>
  35.         <form name="auto_compatible" onSubmit="calculate()">
  36.         <tr>
  37.         <td width="153">&nbsp;</td>
  38.         <td>
  39.             Weight: <select name="type">
  40.             <option value="1@.37@.39@.02">1oz</option>
  41.             <option value="2@.607@.63@.023">2oz</option>
  42.             </select>
  43.         </td>
  44.         <td>Quantity: <input name="quantity" width="1"></td>
  45.         <td id="final_auto_compatible"></td>
  46.         <td id="full_auto_compatible"></td>
  47.         <td id="savings_auto_compatible"><input type="submit"></td>
  48.         </form>
  49.     </tr>
  50.  
  51.  
  52. </table>
  53.  
  54. </body>
  55. </html>
  56.  
  57.  
thanks for any help

eric
Apr 18 '07 #1
2 1000
hi pal,
if the form isnīt really submitted ,
and send to a cgi.
use this:
Expand|Select|Wrap|Line Numbers
  1.   <table width="800">
  2.     <tr>
  3.         <td width="153">&nbsp;</td>
  4.         <td>Weight</td>
  5.         <td>Quantity</td>
  6.         <td>Final Cost</td>
  7.         <td>Full Rate</td>
  8.         <td>Savings</td>
  9.     </tr>
  10.     <tr>
  11.         <td colspan="6">Auto Compatible Letters</td>
  12.     </tr>
  13.         <form name="auto_compatible" onSubmit="return false;">
  14.         <tr>
  15.         <td width="153">&nbsp;</td>
  16.         <td>
  17.             Weight: <select name="type">
  18.             <option value="1@.37@.39@.02">1oz</option>
  19.             <option value="2@.607@.63@.023">2oz</option>
  20.             </select>
  21.         </td>
  22.         <td>Quantity: <input name="quantity" width="1"></td>
  23.         <td id="final_auto_compatible"></td>
  24.         <td id="full_auto_compatible"></td>
  25.         <td id="savings_auto_compatible"><input onclick="calculate()"type="submit"></td>
  26.         </form>
  27.     </tr>
  28.  
  29.  
  30. </table>
  31.  
peace
Apr 19 '07 #2
tolkienarda
316 100+
hey thanks
one more question
when i call the function calculate() from the submit button how would i go about sending a string into that function
could i just - calculate('string')
or do i need to have some more javascript.

eric
Apr 19 '07 #3

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

Similar topics

6
by: Paul | last post by:
Hi, I've been trying for some time now to get the height (the 'scrollable' height) of the current page (Thanks to Martin Honnen for help so far). I feel as though I am almost there, but am having...
1
by: Stefan De Schepper | last post by:
Hi all, I made an overview of all my contacts. This overview is shown in a ListView. I programmatically add as many columns as there are in my contacts database table. All the contacts and their...
6
by: D Witherspoon | last post by:
My application takes 5 or 6 seconds to load because of the time required to communicate with web services and load from the database. In the meantime I'd like to show a splash screen in a seperate...
2
by: tarmstrong | last post by:
Hi. I would like to create a link next to a caption, and when user clicks it, a new text appears and becomes . And when users clicks , it becomes and the text dissapears. I don't...
7
by: Matt | last post by:
Is there a way to increase the amount of time a hyperlink title displays or show the desired text using javascript? <a title="This is the title text displayed on hover.">Displayed Text</a> ...
9
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
3
by: Matthew C | last post by:
Hello, I have a single line input box and when it is set to "password" the value in it dissapears during form submits, but persists when simply set to "text". How do I set and or persist the...
4
by: Mark L. Breen | last post by:
Hello Guys and Galls, I use combos on my forms. The code to initialise the combos is as follows Dim dsPIDTypes As DataSet dsPIDTypes = PartDB.GetPIDTypes ' Returns a dataset object...
2
by: george.leithead | last post by:
Hi all, I have a very strange problem! In following Web page (which is generated from a CMS System), the navigation to the left 'dissapears' when you roll the mouse over the links? It does not...
4
by: Mudcat | last post by:
I've tried quite a few things to get this correct but have hit a couple of sticking points that I can't figure out. I need to ge the Text box to function like the 'wraplength' option in a Label. ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.