Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2007, 05:06 AM   PM User | #1
bunny1
New Coder

 
Join Date: Feb 2007
Posts: 92
Thanks: 1
Thanked 0 Times in 0 Posts
bunny1 is on a distinguished road
call

i have a javascript function i want to call within my php script
where should i place the javascript.
bunny1 is offline   Reply With Quote
Old 03-24-2007, 05:27 AM   PM User | #2
iLLin
Regular Coder

 
Join Date: Oct 2005
Location: Right Here
Posts: 654
Thanks: 1
Thanked 0 Times in 0 Posts
iLLin is an unknown quantity at this point
Anywhere you want before the call.
iLLin is offline   Reply With Quote
Old 03-24-2007, 05:32 AM   PM User | #3
bunny1
New Coder

 
Join Date: Feb 2007
Posts: 92
Thanks: 1
Thanked 0 Times in 0 Posts
bunny1 is on a distinguished road
it doesnt seem to recognise it when it's in the head tag.
can it be within the php script?
bunny1 is offline   Reply With Quote
Old 03-24-2007, 05:34 AM   PM User | #4
iLLin
Regular Coder

 
Join Date: Oct 2005
Location: Right Here
Posts: 654
Thanks: 1
Thanked 0 Times in 0 Posts
iLLin is an unknown quantity at this point
Post up some code on what your trying to accomplish.
iLLin is offline   Reply With Quote
Old 03-24-2007, 05:38 AM   PM User | #5
bunny1
New Coder

 
Join Date: Feb 2007
Posts: 92
Thanks: 1
Thanked 0 Times in 0 Posts
bunny1 is on a distinguished road
thanks


Code:
<head>

<script language="JavaScript">

function UpdateQty(item)
{
itemId = item.name;
newQty = item.options[item.selectedIndex].text;

document.location.href = 'cart.php?action=update_item&id='+itemId+'&qty='+newQty;
}

</script>
PHP Code:
<?php
.......
echo 
"<select name='" $row['Product_ID'] . "' onChange='" UpdateQty(this) . "'>";
....
?>
bunny1 is offline   Reply With Quote
Old 03-24-2007, 05:41 AM   PM User | #6
iLLin
Regular Coder

 
Join Date: Oct 2005
Location: Right Here
Posts: 654
Thanks: 1
Thanked 0 Times in 0 Posts
iLLin is an unknown quantity at this point
Your trying to make the javascript call a php call. Change to this

PHP Code:
<?php
.......
echo 
"<select name='" $row['Product_ID'] . "' onChange='UpdateQty(this)'>";
....
?>
iLLin is offline   Reply With Quote
Old 03-24-2007, 05:49 AM   PM User | #7
bunny1
New Coder

 
Join Date: Feb 2007
Posts: 92
Thanks: 1
Thanked 0 Times in 0 Posts
bunny1 is on a distinguished road
ok thanks!
bunny1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:43 PM.


Advertisement
Log in to turn off these ads.