LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   javascript calls to embedded echo'd php forms (https://www.linuxquestions.org/questions/programming-9/javascript-calls-to-embedded-echod-php-forms-354075/)

xemous 08-17-2005 12:05 AM

javascript calls to embedded echo'd php forms
 
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 !

xemous 08-21-2005 06:29 AM

I'm just bumping this thread incase any php gurus missed it.


All times are GMT -5. The time now is 05:32 AM.