LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 12:05 AM   #1
xemous
Member
 
Registered: Jun 2004
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, 06:29 AM   #2
xemous
Member
 
Registered: Jun 2004
Posts: 80

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


Reply



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 03:27 PM
Best mailer to use for a website with PHP email forms gbkyle Linux - Software 1 07-07-2005 04:00 AM
passing an array from html-forms to php prabhatsoni Linux - Software 2 06-04-2005 12:11 AM
accessing forms elements with javascript djgerbavore Programming 2 06-03-2005 02:32 PM
HTML, PHP, forms, submitting data Problem Silent1 Programming 3 08-31-2004 03:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:04 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration