problem making query string in URL work (trivia game)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Simmons

    #1

    problem making query string in URL work (trivia game)

    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


  • Vincent van Beveren

    #2
    Re: problem making query string in URL work (trivia game)

    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.locati on.href;
    s = s.substring(s.i ndexOf("?")+1);
    while (s.length>p.len gth) {
    if (s.substring(0, p.length)==p) {
    end = s.indexOf("&");
    if (end<0) end = s.length;
    return unescape(s.subs tring(p.length, end));
    }
    if (s.indexOf("&") >0) {
    s = s.substring(s.i ndexOf("&")+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:
    [color=blue]
    > 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
    >
    >[/color]

    Comment

    • Tim Simmons

      #3
      Re: problem making query string in URL work (trivia game)

      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:


      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" <vincent@provid ent.nl> wrote in message
      news:406d5938$0 $561$e4fe514c@n ews.xs4all.nl.. .[color=blue]
      > 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.locati on.href;
      > s = s.substring(s.i ndexOf("?")+1);
      > while (s.length>p.len gth) {
      > if (s.substring(0, p.length)==p) {
      > end = s.indexOf("&");
      > if (end<0) end = s.length;
      > return unescape(s.subs tring(p.length, end));
      > }
      > if (s.indexOf("&") >0) {
      > s = s.substring(s.i ndexOf("&")+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:
      >[color=green]
      > > I am stumped. I encoded the action = of my form using GET and I can't[/color][/color]
      seem[color=blue][color=green]
      > > to get the property/value stuff from it using a JavaScript script I got[/color][/color]
      from[color=blue][color=green]
      > > the web.
      > >
      > > I want to create a trivia game where the user gets 1 question at a time[/color][/color]
      and[color=blue][color=green]
      > > it keeps scoring until the end and gives a summary and I want to do it[/color][/color]
      only[color=blue][color=green]
      > > 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.[/color][/color]
      I[color=blue][color=green]
      > > found a Beatles trivia game but it was using frames and hidden[/color][/color]
      JavaScript[color=blue][color=green]
      > > source files and that's too much work to try and figure out all of that.
      > >
      > >
      > > Any help is appreciated.
      > >
      > >
      > > Thanks,
      > > Tim
      > >
      > >[/color]
      >[/color]


      Comment

      Working...