This topic is locked

Need help with code

4/16/2009 11:41:20 AM
PHPRunner General questions
R
racerx author

Hello Everyone,
I have this code working what it does it takes what ever the user enters in the in the Invoice Amount field and puts the same value in the Purchase Amount field

so the user only enters it once but what I can't figure out is if I put a negative amount for example -25.00 in the Invoice Amount field how do I get it to go into the Credit Amount field I have being trying but no joy .Thanks in advance.
[codebox]x.onchange = x.onkeyup = function()

{

var Invoice_Amount = document.forms.editform.value_Invoice_Amount.value;
document.forms.editform.value_Purchase_Amount.value = Number(Invoice_Amount) ;

}

</script>{/literal}[/codebox]
Regards,

racerx

G
garethpDevClub member 4/16/2009

I may be able to offer a little help whilst you wait for the experts!
This is a code I use...

<script>

var vv = document.editform.value_unit_price;

var ww = document.editform.value_quantity;

vv.onchange = vv.onkeyup =ww.onchange = ww.onkeyup =function() {

var qty = document.editform.value_quantity.value;

var unit = document.editform.value_unit_price.value;

document.editform.value_net_value.value =parseFloat(qty)*parseFloat(unit);}

</script>


With your code...

x.onchange = x.onkeyup = function(){

var Invoice_Amount = document.forms.editform.value_Invoice_Amount.value;

document.forms.editform.value_Purchase_Amount.value = Number(Invoice_Amount) ;}

</script>{/literal}


Have you started with {literal}<script>?You may be able to remove literals depending on which phprunner you are using.

Also have you defined the var invoice - see first line of my code.
Hope this helps

R
racerx author 4/16/2009

I may be able to offer a little help whilst you wait for the experts!

This is a code I use...
With your code...
Have you started with {literal}<script>?You may be able to remove literals depending on which phprunner you are using.

Also have you defined the var invoice - see first line of my code.
Hope this helps


Hello Thanks ,
Looks like some of my code got chopped off tried your code but I must be doing something wrong must admit I'm bit of a newbie can you post a example how you would combine the code I just can't get my head around it any help would be great below is the full block of code that is working and that I want to expand on thanks in advance.
[codebox]{literal}<script>

var x = document.forms.editform.value_Invoice_Amount;

x.onchange = x.onkeyup = function()

{

var Invoice_Amount = document.forms.editform.value_Invoice_Amount.value;
document.forms.editform.value_Purchase_Amount.value = Number(Invoice_Amount) ;

}

</script>{/literal}[/codebox]
Regards,

racerx