Reply
Php Help!!
Old 03-19-2008, 07:43 PM Php Help!!
RCS
Novice Talker

Posts: 7
I'M TRYING TO CHANGE THE FOLLOWING JAVASCRIPT TO PHP, CAN SOMEONE PLEASE GIVE ME A RUN DOWN OF HOW TO GO ABOUT THIS??? THANKS IN ADVANCE

function calculate(num) {
var tax_on = 0;
var tax_to = 0;

num = num.replace(/[^0-9\.]/g,'');
if ( num <= 55000 ) {
tax_on = (num*0.005);
tax_to = (num*0.005);
}
if ( num > 55000 && num <= 250000 ) {
tax_on = (num*0.01)-275;
tax_to = (num*0.01)-275;
}
if ( num > 250000 && num <= 400000 ) {
tax_on = (num*0.015)-1525;
tax_to = (num*0.01)-275;
}
if ( num > 400000 ) {
tax_on = (num*0.02)-3525;
tax_to = (num*0.02)-4275;
}
var Sum = tax_on + tax_to;


document.forms.the_form.tax_on.value = format(tax_on,2);
document.forms.the_form.tax_to.value = format(tax_to,2);
document.forms.the_form.sum.value = format(Sum,2);

}
function calculate_com(num) {
var tax_on2 = 0;
var tax_to2 = 0;

num = num.replace(/[^0-9\.]/g,'');
if ( num <= 55000 ) {
tax_on2 = (num*0.005);
tax_to2 = (num*0.005);
}
else if ( num > 55000 && num <= 250000 ) {
tax_on2 = (num*0.01)-275;
tax_to2 = (num*0.01)-275;
}
else if ( num > 250000 && num <= 400000 ) {
tax_on2 = (num*0.015)-1525;
tax_to2 = (num*0.01)-275;
}
else if ( num > 400000 && num <= 40000000 ) {
tax_on2 = (num*0.015)-1525;
tax_to2 = (num*0.015)-2275;
}
else {
tax_on2 = (num*0.015)-1525;
tax_to2 = (num*0.01)+197725;
}
var Sum2 = tax_on2 + tax_to2;


document.forms.the_form2.tax_on2.value = format(tax_on2,2);
document.forms.the_form2.tax_to2.value = format(tax_to2,2);
document.forms.the_form2.Sum2.value = format(Sum2,2);

}
function format(no, dp)
{
dp = Math.pow(10, dp);
var no = (Math.round(no * dp) / dp) + "";
var first = no.split(".");
var tmp = new Array;
var counter = 0;
var start = first[0].length % 3;
if (start) tmp[counter++] = first[0].substr(0, start);
for (var i = start ; i < first[0].length ; i += 3)
tmp[counter++] = first[0].substr(i, 3);
first[0] = tmp.join(',');
return "$"+first.join('.');
}
RCS is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-20-2008, 02:35 AM Re: Php Help!!
Junior Talker

Posts: 3
www.google.com


Look for a converter.
joshsavage91 is offline
Reply With Quote
View Public Profile
 
Old 03-20-2008, 03:37 AM Re: Php Help!!
mtishetsky's Avatar
King Spam Talker

Posts: 1,120
Name: Mike
Location: Mataro, Spain
Wtf. Do you know that php runs on server and js runs on client? Even if you find the converter you won't be able to convert this code as is because it refers to document elements, probably to obtain some values from the outer world.
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-20-2008, 09:21 PM Re: Php Help!!
Novice Talker

Posts: 5
Too much code to read.. what do you want the PHP to do exactly?
psychdev is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Php Help!!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12155 seconds with 12 queries