LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-17-2005, 01:05 AM   #1
xemous
Member
 
Registered: Jun 2004
Location: Australia, Melbourne.
Distribution: Ubuntu
Posts: 80

Rep: Reputation: 15
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 !
 
Old 08-21-2005, 07:29 AM   #2
xemous
Member
 
Registered: Jun 2004
Location: Australia, Melbourne.
Distribution: Ubuntu
Posts: 80

Original Poster
Rep: Reputation: 15
I'm just bumping this thread incase any php gurus missed it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL results to html forms using PHP xemous Programming 3 08-15-2005 04:27 PM
Best mailer to use for a website with PHP email forms gbkyle Linux - Software 1 07-07-2005 05:00 AM
passing an array from html-forms to php prabhatsoni Linux - Software 2 06-04-2005 01:11 AM
accessing forms elements with javascript djgerbavore Programming 2 06-03-2005 03:32 PM
HTML, PHP, forms, submitting data Problem Silent1 Programming 3 08-31-2004 04:03 PM


All times are GMT -5. The time now is 12:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration