[Javascript] Print the contents of a variable into the source

Laurent Muchacho LaurentM at london.virgin.net
Fri Aug 20 09:58:13 CDT 2004


Hi 

>From what I get you need to pickup the value from the querystring is that
right 
If that is what you want to do then it's pretty easy
this is your url results.php?kbps=1500
 
in ASP you will use 
dim myVar : myVar = request.querystring("kbps") 
response.write myVar

in javascript there is no object that let you that but you write your own 

function QueryString(param){
	var loca = document.location.href;
	if(loca.indexOf('?' + param + '=')>-1 || loca.indexOf('&' + param +
'=')>-1){
		var qString = loca.split('?');
		var keyVal = qString[1].split('&');
		for(var i=0;i<keyVal.length;i++){
			if(keyVal[i].indexOf(param + '=')==0){
				var val = keyVal[i].split('=');
				return val[1];
			}
		}
		return false;
	}else{
		return false;
	}
}

then you can do something like this

var myVar = QueryString("kbps");
document.write (myVar)

there is an examples pages

http://www.be-lovely.co.uk/querystring/index.html

Laurent

-----Original Message-----
From: Chris Nafziger [mailto:CNafziger at sauder.com]
Sent: 20 August 2004 14:50
To: [JavaScript List]
Subject: RE: [Javascript] Print the contents of a variable into the
source


Right; that's not the problem... Getting the actual number (Value) to show
up somewhere... ANHYWHERE in the source is the problem... Of course you are
correct about the ASP; I could do it easily in ASP, but I cannot use it
here.  I'm looking (probably in vain) for a pure JavaScript solution.  I'm
thinking perhaps a couple native JS functions could get me to the point that
a new variable KBPS789=789 if that's what kbps contains, but you still
wouldn't actually see 789 in the source.  Anybody else have any ideas?

-----Original Message-----
From: Allard Schripsema [mailto:allard-schripsema at procergs.rs.gov.br] 
Sent: Friday, August 20, 2004 8:30 AM
To: [JavaScript List]
Subject: RE: [Javascript] Print the contents of a variable into the source

Hi Chris,
I don´t get it.
i guess if the variable is known, you can do a document.write,  innerText,
objectx.value or something like that to show it.
But that´s probably not the problem right?

To make kbps appear in the source  you´d have to use a server side script ,
and that means kbps is known at the server ( in asp and asp.Net:
<%response.write("<!--" & kbps & "-->")%> )

If the kbps is determined using javascript, you cannot do what you want to
do at the moment you want.
you could consider reloading the same page sending your kbps in the
querystring (or form, whatever) and getting it serverside and print it then.

hope that helps,

Allard Schripsema





-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Chris Nafziger
Sent: Thursday, August 19, 2004 7:09 PM
To: [JavaScript List]
Subject: [Javascript] Print the contents of a variable into the source


Really need some help on this one...  Seemed easy enough at first...

nextpage='results.php?kbps=' + kbps;
// what can I do here to print the contents of the nextpage variable
somewhere in the source?
document.location.href=nextpage;


<!--nextpage=results.php?kbps=1500-->
Or
//nextpage=results.php?kbps=1500

....is what I need to see so it doesn't show up on the HTML page

It's a long story involving SQL running a scheduled stored proc that
executes pings, parses the results, summarizes the results, and sticks it in
a database, along with this kbps value, retrieved from the source via a
command line utility executed by the same stored procedure, so I end up with
a table containing a constantly accumulating summary of speed, latency, and
routing.

I just need to get the contents of that variable into the source, so my
parser can pick it up.

Changing the other two lines of code, the other pages in the web, et cetera,
is not an option.  Like I said... Long story.

How do I print the contents of a variable into the source?





-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

This e-mail and any files transmitted with it may contain privileged,
confidential, or proprietary information which may be protected from
disclosure under law, and is intended solely for the use of the individual,
group, or entity to whom this e-mail is addressed.  If you are not one of
the named recipients, please notify the sender by e-mail and delete this
message immediately from your computer.  Any other use, retention,
dissemination, forwarding, printing, or copying of this e-mail is strictly
prohibited.  Thank you for your assistance.

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript


This E-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.  If you have received this E-mail in error please notify the system manager.  This message contains confidential information and is intended only for the individual named.  If you are not the named addressee you should not disseminate, distribute or copy this E-mail.



More information about the Javascript mailing list