Wayniac Posted July 6, 2010 Share Posted July 6, 2010 Below is my previous code I had working in the manner it would change the price, sub_total, tax, sh, total, and total_paid input fields to 0. There are two problems with this... 1. When it outputs to the input fields, the value displays as 0 instead of 0.00. 2. I need to have it only react when the value typed into the input field "trees_sold" is "0". If any higher, I would like it to ignore the statement. <!-- Comp all prices to zero value --> <SCRIPT LANGUAGE="JavaScript"> var trees_sold = 0.00; function InitSaveVariables(form) { price = form.price.value; sub_total = form.sub_total.value; tax = form.tax.value; sh = form.sh.value; total = form.total.value; total_paid = form.total_paid.value; } function CompPrices(form) { if (trees_sold == 0.00) { InitSaveVariables(form); form.price.value = 0.00; form.sub_total.value = 0.00; form.tax.value = 0.00; form.sh.value = 0.00; form.total.value = 0.00; form.total_paid.value = 0.00; } } </script> <input name="trees_sold" id="trees_sold" size="15" onkeyup="javascript:CompPrices(this.form);" maxlength="15" /> Below is my current code I'm working with that I can't seem to get to function properly. I've modified the first two lines of code here, and am attempting to pull any data that is typed in and automatically take into consideration if it is a "0" value, it reacts as my code below says "if (trees_sold == 0.00)" and if anything else, it will not do anything. This is not working unfortunately. <!-- Comp all prices to zero value --> <SCRIPT LANGUAGE="JavaScript"> form.trees_sold.value = ""; trees_sold = form.trees_sold.value; function InitSaveVariables(form) { price = form.price.value; sub_total = form.sub_total.value; tax = form.tax.value; sh = form.sh.value; total = form.total.value; total_paid = form.total_paid.value; } function CompPrices(form) { if (trees_sold == 0.00) { InitSaveVariables(form); form.price.value = 0.00; form.sub_total.value = 0.00; form.tax.value = 0.00; form.sh.value = 0.00; form.total.value = 0.00; form.total_paid.value = 0.00; } } </script> <input name="trees_sold" id="trees_sold" size="15" onkeyup="javascript:CompPrices(this.form);" maxlength="15" /> Anyone have any ideas? Thank you. Quote Link to comment Share on other sites More sharing options...
Wayniac Posted July 7, 2010 Author Share Posted July 7, 2010 If I can reword or explain a specific section in more detail, please let me know and I'll do so. Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.