Solved

execute php inside javascript code.

Posted on 2007-11-19
5
2,351 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 50

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 50

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

803 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