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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass variables through url? 1

Status
Not open for further replies.

idtstudios2

Programmer
Aug 12, 2005
35
0
0
US
I'm trying to pass javascript variables through an URL and I can't seem to get it correct. I think you can tell what i'm trying to do. I just don't know how to do it

<script type="text/javascript"><!--
tag_type = "personal";
tag_content = "political";
//--></script>

<script type="text/javascript"
src="</script>

i'm using a php script to generate the javascript if anyone is confused about the .php extension.

Any help would be appreciated, thanks.
 
[red]document.location[/red]="[red]"+tag_type+"[/red]&tag_content=[red]"+tag_content;[/red]

'hope that helps.

--Dave



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
:( doesn't help much. Thanks for trying though. I need the variables to be passed in the source URL. Thanks again :)
 
You cannot use a php file as an imported javascript file. It has to be a .js file. What exactly are you trying to do?

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
images
 
actually the php file just outputs javascript after running the passed variables througha database check. everything works fine except the variables.
 
You can either:
a. use document.write to write out the correct script tag (deprecated!)
b. use DOM methods to create a script element and insert it into the head.

also, you may need to set the correct mime type in the php file:
Code:
<?php 
  header("Content-type: text/javascript");
?>

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
Thank you very much I chose the DOM method and everything works great now. Thanks :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top