Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-03 09:18:32

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Pass variables in query string to javascript?

Newb question. I’ve like to using the following link…

<script src=“js/fall09.js?gallery=10145677_gXk2L” type=“text/javascript”></script>

…and insert the gallery variable where this appears 10145677_gXk2L in the following code…

   .slideDown("slow", function(){
                  var scast = new SWFObject("http://kadampafestivals.org/embed/monoslideshow.swf", "scHtmlTags", "640px", "480px", "8", "#000000");
                  scast.addParam("quality", "high");
                  scast.addParam("loop", "false");
                  scast.addParam("allowScriptAccess", "sameDomain");
                  scast.addParam("menu", "false");
                  scast.addParam('flashvars','&dataFile=http://kadampafestivals.org/2009/fall-gallery/10145677_gXk2L/&showRegistration=false&showLogo=false');
                  $("#content").append('<div id="feature_video"></div>');
                  scast.write("feature_video");
                  });

Last edited by FireFusion (2009-11-03 09:22:19)

Offline

#2 2009-11-03 09:39:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,293
Website GitHub

Re: Pass variables in query string to javascript?

adi_gps is probably easiest because it assigns all URL vars to txp:variables.

<txp:adi_gps />
...
.slideDown("slow", function(){
                  var scast = new SWFObject("http://kadampafestivals.org/embed/monoslideshow.swf", "scHtmlTags", "640px", "480px", "8", "#000000");
                  scast.addParam("quality", "high");
                  scast.addParam("loop", "false");
                  scast.addParam("allowScriptAccess", "sameDomain");
                  scast.addParam("menu", "false");
                  scast.addParam('flashvars','&dataFile=http://kadampafestivals.org/2009/fall-gallery/<txp:variable name="gallery" />/&showRegistration=false&showLogo=false');
                  $("#content").append('<div id="feature_video"></div>');
                  scast.write("feature_video");
                  });

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB