Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 29th, 2006, 04:07 PM
Authorized User
 
Join Date: Apr 2006
Location: bikaner, raj, India.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to chayanvinayak
Default adding php code in javascript

How can i add php script inside javascript function with variable of javascript .


so far i have tried following but its not working :

function(){
var any=100;
document.write("<?php mysql_query(\"INSERT INTO table VALUES "+any+"") ?>");
}



chayan vinayak goswami
__________________
chayan vinayak goswami
Reply With Quote
  #2 (permalink)  
Old October 31st, 2006, 05:37 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Vinayak!!
You can't do this,since ur php code is server side script, and ur client side javascript variable can't be accessed at the same time.
you can use ajax or use iframe to share the client side variables with server side scripts.
hope this will help you



Cheers :)

vinod
Reply With Quote
  #3 (permalink)  
Old December 18th, 2006, 02:33 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 481
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hai,
try this, but i don't know how this working
<script language="JavaScript" type="text/javascript">
<!-- //
var any=100;
document.write(<?php echo any?>);
// -->
</script>


surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to embed javascript in php code scoobie PHP How-To 8 November 28th, 2007 02:11 PM
adding checkbox to datagrid using javascript k.manisha ASP.NET 1.0 and 1.1 Professional 0 June 4th, 2007 11:02 PM
adding items to list box using javascript k.manisha ASP.NET 1.0 and 1.1 Professional 3 February 16th, 2007 06:32 AM
adding a class in JavaScript crmpicco Javascript How-To 5 October 4th, 2005 08:15 AM
Adding javascript to popups chrscote Javascript How-To 2 June 8th, 2005 04:34 AM



All times are GMT -4. The time now is 04:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.