Jump to content

passing the id= php variable on page load.


Recommended Posts

I'm using a chat script I've made and the script has 2 seperate files the hub.php and the chat.php page.  The hub.php has the form and sends the info to the chat.php page where it adds to the chat. 

 

I need the hub.php to send a variable through javascript to the chat.php on page load and not on the form submit.

 

What I'm passing is the page id.. Example: http://mysite.com/hub.php?id=dkjhf3883

 

What could I add here?

 

I've got the id defined as $hubid in php.

 

<div id="chat">Connecting...</div>
 <input id="message" type="text" size="53" maxlength="100" onkeyup="keyup(event);" />
<input type="button" value="Submit" onclick="chat_write();" /><br />
<script language="JavaScript" type="text/javascript" src="./chat.php"></script>

 

Thanks! if you need more of the script or don't understand feel free to ask.

Is the chat.php file a PHP file that generates Javascript code?

 

You could try two things. Either

<script language="JavaScript" type="text/javascript" src="./chat.php?id=<?=$hubid?>"></script>

or something completely different, like an include. Like this (in place of the <script> line):

<script language="JavaScript" type="text/javascript">

<?php

include ("./chat.php?id=$hubid");

?>

</script>

 

Yep.  Thanks a whole lot.

 

I tried those and on my chat.php page I put a

 

$hubid = $_GET['id'];

 

And the chat is generating a txt file so I'm putting this code

 

$fn = $hubid.txt;

 

It's just creating a .txt file.  I'm not sure how I grab the variable  :-\

 

 

I'm just saying, that unless you have a specify crucial reason to use it

There is no point in using javascript....

 

If we knew why he was passing it to Javascript in the first place, I'm sure things would make more sense

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.