Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How do I pass a url parameter through javascript to html

Former Member
0 Likes
508

Hi everyone,

Does anyone have knowledge of how to pass a URL parameter to a javascript block? For example, I have a URL parameter called "Machine" in the URL below:

http://xmiidevvs/Illuminator/xmiitest/Hamel.irpt?Machine=1

When I try to reference this parameters value in the javascript code, the results are a blank screen (errors out).

Please see my javascript below:



<!--
var Node
Node = {Machine}*2+9   //This does not Work!!!!!/////

document.write("<APPLET NAME='{Machine} Chart' CODEBASE='/Illuminator/Classes'  CODE='iChart' ARCHIVE='illum8.zip' WIDTH='640' HEIGHT='400'   MAYSCRIPT>")
document.write("<PARAM NAME='QueryTemplate'     VALUE='iHistorian/Minutes/TurnMinutesTagname'>")
document.write("<PARAM NAME='DisplayTemplate'   VALUE='iHistorian/Minutes/AllTurnMinutes'>")
document.write("<PARAM NAME='ChartType'         VALUE='Bar'>")
document.write("<PARAM NAME='Title'             VALUE='{Machine}'>")
document.write("<PARAM NAME='Tagname.1' VALUE='OPCSERVER.USBtoCAN.Node " + Node + ".AmberMinutes'>")
document.write("</APPLET>")
//-->

Thanks to all!

Mike

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
435

Hi Mike,

Here's a function to get the value of the 'Machine' url param.


function getMachine()
{
   var m = window.location.search.match(/Machine=(w+)&?/);	 
   return m[1];
}

So you can do:


var machine = getMachine();

Regards

Gregor

1 REPLY 1
Read only

Former Member
0 Likes
436

Hi Mike,

Here's a function to get the value of the 'Machine' url param.


function getMachine()
{
   var m = window.location.search.match(/Machine=(w+)&?/);	 
   return m[1];
}

So you can do:


var machine = getMachine();

Regards

Gregor