Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling JavaScript

Status
Not open for further replies.

VisBasDude

Programmer
Nov 10, 2002
19
GB
Hi again. Sorry to keep asking questions but you all seem to be able to help me which is good! Anyway is it possible to call a javascript function from php. If so how would you go about it. Once again thanx everyone for your help. James
 
No, as so many other times stated in this forum, JavaScript is client side and PHP is server side. //Daniel
 
Actually Daniel, according to something I read just last night, Javascript is now being used server side also.

James, you may be asking the wrong question. JavaScript and PHP can be used in combination (indirectly). What do you want to do? Clive
 
CliveC,
JavaScript has been used on the server side for ages, though the amount of people using it for that purpose is close to zero. //Daniel
 
All that said, it is possible for server-side PHP to get data from client-side JavaScript. Call it a delayed remote procedure call.

For example, if PHP produces an HTML form with a hidden field and sufficient inline JavaScript code to populate that field, when the form is submitted, JavaScript-produced data can be returned to PHP. Something like this could be useful to obtain information about the user's environment that isn't reported by the browser in its HTTP headers. Want the best answers? Ask the best questions: TANSTAAFL!
 
Well i want a piece of code from php that will call and load a page into another frame! Im not sure if this is possible though.
 
You can also send info from an html page using an image and javascript ie without a form using a get request. This is useful for picking up info not available from PHP ie users Screen size colour depth etc. This can be done as follows.

<img src=&quot;filename.php?@varname=varvalue&quot;>

this will pass info to your php script where you can retrieve the values. The only other thing to remember is to put

header(&quot;Location: yourimage.gif&quot;);

somewhare inyour script.
Hope this helps
Ian It's not a lie if you believe it!

 
VisBasDude:

Have PHP output a JavaScript script necessary to change one frame's location attribute from another.


In terms of PHP, it's little more than a print statement. The real meat of the issue is a JavaScript question, which should be asked in a different forum. Want the best answers? Ask the best questions: TANSTAAFL!
 
I tried doing that going Print(RoutinetoCall()); and it didnt like it saying that a routine was been called which is not there. It is on the same page the function but maybe not in the right place! Where would you put it??
 
You're going to have to do something like the following:

Code:
print 'A bunch of HTML...';
print '
<script language=&quot;JavaScript&quot;>
  some.javascript.object.attribute.reference = somevalue;
or
Code:
  some.javascript.object.method(somevalue);
</script>';
print 'Some more HTML....';
Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top