I'm having another issue with my forms,
I had to embed them in php so I used echo's (because they are generated as needed in a loop from a database of searched books)
I need to somehow take the input tag for quantity and multiply it by the price, which is in a hidden field, then take that value and and give to the price field, which is a readonly input tag.
I created a new webpage in html with a form very similar and wrote this code in javascript
Code:
<script language="javascript">
function dollars(n) {
n=eval(n);
n=Math.round(n*100)/100;
return (n == Math.round(n)) ? n += ".00" : (n*10 == Math.round(n*10)) ? n +="0" : n;
}
function total_price() {
s1 = eval(document.browse.quantity.value);
s2 = eval(document.browse.price.value);
document.browse.total.value = dollars(s1+s2);
}
</script>
It works,
But on the php embedded code it doesn't, it wont call the jscript functions for some reason, I even embedded the actualy jscript with an echo just above the form tags IN PHP CODE, and it still wont work. I can echo stuff in jscript while its imbedded but this more complex stuff doesn't work.
Any know how I can make it work, or, the equivalent
Code:
<script language="javascript">
function dollars(n) {
n=eval(n);
n=Math.round(n*100)/100;
return (n == Math.round(n)) ? n += ".00" : (n*10 == Math.round(n*10)) ? n +="0" : n;
}
function total_price() {
s1 = eval(document.browse.quantity.value);
s2 = eval(document.browse.price.value);
document.browse.total.value = dollars(s1+s2);
}
</script>
in a php function that will work
Cheers !