Solved

execute php inside javascript code.

Posted on 2007-11-19
5
2,336 Views
Last Modified: 2008-02-01
I have the following piece of javascript/php.  It doesn't work.  Any thoughts?  Oh and the javascript is inside a .js file and I can't put the javascript inside the browser script tags.
var postForm =
                  '<form id="ys-post-form"' + (this.prefs.inverse ? 'class="ys-inverse"' : '' ) + '><fieldset>' +
                        '<input id="ys-input-nickname" value="<?php echo $userdata['username']; ?>" type="text" accesskey="N" maxlength="' + this.prefs.nicknameLength + '" class="ys-before-focus" />'
0
Comment
Question by:casit
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 20317824
try rename that js file to .php and try again?
0
 

Author Comment

by:casit
ID: 20317834
0
 

Author Comment

by:casit
ID: 20317855
Sorry meant to say that I did try renaming it and still the same results.
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 20318004
try change lines:

<script src="yshout/js/yshout.php" type="text/javascript"></script>

to:

include('yshout/js/yshout.php');

and inside yshout/js/yshout.php, add:

<script language="javascript">

at top and,

</script>

at the bottom of the file.


see if this works?
0
 

Author Comment

by:casit
ID: 20318166
No that didn't work but unfortunatelty this feature has been moved down to the bottom of the project list at the moment.  I will however award you the points.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now