Click to See Complete Forum and Search --> : Passing variables using querystring


Quinnr
03-27-2004, 12:28 AM
Hi,
I am trying to pass the variables txtReq1 - txtReq5 to "ReqEnterMore.asp", how do I do it correctly using the OnClick line below?I know I have to have querystring in the "ReqEnterMore.asp", but cant get any of the required variables. Is this even the correct way of trying to do it??


<form action="PrecedenceForm.asp" method="post" name="ReqEnterForm">
Please Enter Requirements
r1 <input type="text" name="txtReq1">
r2 <input type="text" name="txtReq2">
r3 <input type="text" name="txtReq3">
r4 <input type="text" name="txtReq4">
r5 <input type="text" name="txtReq5">

<input type="submit" value="Save" name="ReqEnterSave">
<input type="button" value="More" name="ReqEnterMore"
Onclick=window.location.href="ReqEnterMore.asp?Requirement1=txtReq1">
</form>


I'd greatly appreciate any help anyone can provide,

Regards,

Ruairi

buntine
03-27-2004, 12:57 AM
Mixing JavaScript and ASP is a bad idea.

Though, you have to call a function which will construct the new URL.

onclick="createUrl();"

function createUrl()
{
var txtCtrlName = "txtReq";
var fileUrl = "ReqEnterMore.asp";
var fileQuery = "";

for (var i=0; i<5; i++)
{
if (i == 0) { fileQuery += "?";} else {fileQuery += "&";}
fileQuery += "Requirement" + (i+1) + "=";
fileQuery += document.getElementsByName(txtCtrlName + (i+1))(0).value;
}

//alert(fileUrl + fileQuery); //You might want to uncomment this for debugging.
window.location.href = fileUrl + fileQuery
}


Regards,
Andrew Buntine.

Quinnr
03-27-2004, 01:52 AM
I still cant get it to work

document.getElementsByName(txtReq1)(0).value

doesnt seem to be getting what I type in in the txtReq1 field, it just returns document.getElementsByName(txtReq1)(0).value.


Could there be something im doing wrong??

Ruairi

buntine
03-27-2004, 05:01 AM
I have made some changes to the script i wrote. Try it now.

Its been a long while since i use JS.

Regards.

PeOfEo
03-27-2004, 01:33 PM
Why not just tell him how to do it with all asp, since using java script is going to fail for those with it disabled and then the server side scripts will fail to run too... you would criple the whole darned thing if someone does not have js.

buntine
03-27-2004, 03:40 PM
Look what he is trying to do..

This exact thing cant be done using a SSL. There are more secure, alternate ways to do it from the server, though.

PeOfEo
03-27-2004, 09:54 PM
such as an applet (though these can be a pain). What are the client side capabilities of a servelet btw? I know they can do some things but I want to have it firmly drawn out, would you know buntine?

buntine
03-27-2004, 11:18 PM
Im not sure if you can use servlets on the client-side.. Doesnt that defeat the meaning of 'server-side'?

Are you referring to an applet?

PeOfEo
03-28-2004, 12:47 AM
no, a servelet... i heard you can use them to get users resolution and other things... I am really not to sure. I thought a servlet was just a script that acted like it was its own application....

Stopper31
03-28-2004, 07:48 PM
Originally posted by PeOfEo
Why not just tell him how to do it with all asp, since using java script is going to fail for those with it disabled and then the server side scripts will fail to run too... you would criple the whole darned thing if someone does not have js.
Does anyone have any first-hand testing stats on the percentage of users who have javascript disabled? And if so, what is the focus/topic of the site you're running? I find it hard to believe that many users would disable javascript, but since my site uses it, I must ask!

PeOfEo
03-28-2004, 08:35 PM
No, I have not done this, but I know you would have to test it with a java script (weird huh?). I have looked for it, read numerous site tracking system articles but none of them seem to do it.... I think something called browserhawk can do some client side stuff, but I really do not know. I would be interested to find out myself, as well as resolution tracking.

buntine
03-28-2004, 08:36 PM
It varies between about 11% and 13%. Some people see JavaScript as a security threat.

Regards.

PeOfEo
03-28-2004, 08:41 PM
Oh I did not read the test I though he was asking about how to track i ton his own site. Here are some stats
http://www.thecounter.com/stats/2004/March/index.php
It used to be 13% but all of the stats for this year seem to be much lower, so I dono.... I would think fewer people would have it since more people are using ghecko browsers and that can disable js very easily. Half the time I have js turned off because I just find it annoying, sometimes it is practical but usually not, it leads to ads, no right click scripts, and other things a lot of the time, But because it is so easy to disable and enable I can turn it on for sites with a js dependent navigation so I can use their navigation. So just because a % of people have js off doesnt mean they will keep it off because every so often you get an odd ball like me. For every rose there is a PeoFeo.

Stopper31
03-28-2004, 11:09 PM
Thanks for the input... I guess how I should have worded my question was more like "For the number of people without Javascript, how many of them are because they've disabled it"

In other words, if they come to a site using javascript, can they easily turn it back on? The answer seems YES.

Also, with the percentages noted, would they include spiders and whatnot? I know the general public would not disable javascript, and that more often than not, it would be technical people who, like you said, have it disabled for a reason and could turn it back on!

PeOfEo
03-28-2004, 11:12 PM
You can't tell why a user has it disabled, maybe js killed their father so they hold a grudge, whatever it is it cannot be tracked. But you can compare the % of people who use mozilla ns7 and opera to the number of those without js and draw your own conclusions, but that majority of that 3% of users of the internet that use one of those three probably keeps his js on.