Welcome to WebmasterWorld Guest from 18.205.176.85

Forum Moderators: open

Message Too Old, No Replies

changing some php code into javascript

the server side application isn't conducive to the results i'm seeking

     
6:39 am on Jan 4, 2004 (gmt 0)

Full Member

10+ Year Member

joined:July 11, 2003
posts:232
votes: 0


i have a better understanding of PHP than i do of JavaScript, so i was hoping soemeone could put me on the right path towards converting the following into something JavaScript would do:

<?php

if (!isset($_SESSION['username']) !$result mysql_num_rows($result) == 0 ) {

echo "<IFRAME src='join.php' name='right' width='296' height='302' scrolling='no' name='right'></IFRAME>";

} else {

if(!isset($var)){
echo "<IFRAME src='user.php' name='right' width='296' height='302' scrolling='no' name='right'></IFRAME>";

}elseif($var == "var00"){
echo "<IFRAME src='news.php' name='right' width='295' height='302' scrolling='no' name='right'></IFRAME>";

}elseif($var == "var01"){
echo "<IFRAME src='search.php' name='right' width='295' height='302' scrolling='no' name='right'></IFRAME>";

}elseif($var == "var02"){
echo "<IFRAME src='theory.php' name='right' width='295' height='302' scrolling='no' name='right'></IFRAME>";

}elseif($var == "var03"){
echo "<IFRAME src='collaboration.php' name='right' width='295' height='302' scrolling='no' name='right'></IFRAME>";

}elseif($var == "var04"){
echo "<IFRAME src='songwriting.php' name='right' width='295' height='302' scrolling='no' name='right'></IFRAME>";

}else{

echo "have a nice day.";

}

}

?>

10:49 pm on Jan 4, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 22, 2002
posts:1751
votes: 0


Client-side script can't access any of the variables in
if (!isset($_SESSION['username']) !$result mysql_num_rows($result) == 0 ) {

So if that information is relevant, JavaScript won't do.

In JavaScript it is possible to parse the query-part of a URL: it's called location.search , and methods such as split() and substr() can be useful.

As you have not mentioned whether there is a query string - you also forgot to mention what the script is supposed to do - it's hard to say more. If I were you, I'd stick to PHP working, as its output is not dependent on browser settings.

7:31 am on Jan 5, 2004 (gmt 0)

Full Member

10+ Year Member

joined:July 11, 2003
posts:232
votes: 0


yeah, that's good thinking. I got the whole shebang to work, anyhow . . . it just took a few days of staring at the screen like some kind of magic-eye picture
8:56 am on Jan 5, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 22, 2002
posts:1751
votes: 0


Staring never helped me much... fresh air, fresh coffee, some sleep and, most of all, talking about completely different things with real people usually do the trick ;)
12:57 pm on Jan 5, 2004 (gmt 0)

Full Member

10+ Year Member

joined:July 11, 2003
posts:232
votes: 0


well, i've got the coffee....