By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,919 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,919 IT Pros & Developers. It's quick & easy.

problem making query string in URL work (trivia game)

P: n/a
I am stumped. I encoded the action = of my form using GET and I can't seem
to get the property/value stuff from it using a JavaScript script I got from
the web.

I want to create a trivia game where the user gets 1 question at a time and
it keeps scoring until the end and gives a summary and I want to do it only
in JavaScript (no ASP, PHP, JSP, etc).

I tried submitting the quiz page to itself using a query string to keep
track of question # but no joy.

I can post code if necessary or is there a trivia game engine made for 1
question at a time instead of all on 1 page?
Anyway, I looked on Google at the query string issue til I'm sick of it. I
found a Beatles trivia game but it was using frames and hidden JavaScript
source files and that's too much work to try and figure out all of that.
Any help is appreciated.
Thanks,
Tim
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I think There is a 1024byte limit on the length of an URL. It might be
that there is too much data to be send. That could be the problem. Else
I have a script that can read the parameters of an URL:

function getParameter(p) {
p +="=";
s = document.location.href;
s = s.substring(s.indexOf("?")+1);
while (s.length>p.length) {
if (s.substring(0, p.length)==p) {
end = s.indexOf("&");
if (end<0) end = s.length;
return unescape(s.substring(p.length, end));
}
if (s.indexOf("&")>0) {
s = s.substring(s.indexOf("&")+1);
} else s="";
}
return null;
}

Else you might want to try using cookies or something, or use the hidden
frame technique.

Vincent
Tim Simmons wrote:
I am stumped. I encoded the action = of my form using GET and I can't seem
to get the property/value stuff from it using a JavaScript script I got from
the web.

I want to create a trivia game where the user gets 1 question at a time and
it keeps scoring until the end and gives a summary and I want to do it only
in JavaScript (no ASP, PHP, JSP, etc).

I tried submitting the quiz page to itself using a query string to keep
track of question # but no joy.

I can post code if necessary or is there a trivia game engine made for 1
question at a time instead of all on 1 page?
Anyway, I looked on Google at the query string issue til I'm sick of it. I
found a Beatles trivia game but it was using frames and hidden JavaScript
source files and that's too much work to try and figure out all of that.
Any help is appreciated.
Thanks,
Tim


Jul 23 '05 #2

P: n/a
Hello,

Vincent, I am sending only a few bytes (less than 10) and using cookies is
not a good idea since many have them turned off and I refuse to use frames.

When using a query string, do I have to test it on a web server or will it
work locally w/o a server such as IIS? I know server-side script needs a
server but I have no server-side script in the page. It's all client-side.

When I get the string from the URL it says it is undefined.

Okay, I have posted the two pages here:
http://www.timsimmons.com/origins.htm

The first page sends a number to 2nd page using query string. View the
source to see what I did.

Any help is appreciated. A better way of coding it is also appreciated!
Tim
"Vincent van Beveren" <vi*****@provident.nl> wrote in message
news:40*********************@news.xs4all.nl...
I think There is a 1024byte limit on the length of an URL. It might be
that there is too much data to be send. That could be the problem. Else
I have a script that can read the parameters of an URL:

function getParameter(p) {
p +="=";
s = document.location.href;
s = s.substring(s.indexOf("?")+1);
while (s.length>p.length) {
if (s.substring(0, p.length)==p) {
end = s.indexOf("&");
if (end<0) end = s.length;
return unescape(s.substring(p.length, end));
}
if (s.indexOf("&")>0) {
s = s.substring(s.indexOf("&")+1);
} else s="";
}
return null;
}

Else you might want to try using cookies or something, or use the hidden
frame technique.

Vincent
Tim Simmons wrote:
I am stumped. I encoded the action = of my form using GET and I can't seem to get the property/value stuff from it using a JavaScript script I got from the web.

I want to create a trivia game where the user gets 1 question at a time and it keeps scoring until the end and gives a summary and I want to do it only in JavaScript (no ASP, PHP, JSP, etc).

I tried submitting the quiz page to itself using a query string to keep
track of question # but no joy.

I can post code if necessary or is there a trivia game engine made for 1
question at a time instead of all on 1 page?
Anyway, I looked on Google at the query string issue til I'm sick of it. I found a Beatles trivia game but it was using frames and hidden JavaScript source files and that's too much work to try and figure out all of that.
Any help is appreciated.
Thanks,
Tim

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.