passing values Newbie question

Discussion in 'Javascript' started by Angi, Nov 2, 2004.

  1. Angi

    Angi Guest

    I have looked through the first 672 messages and haven't found
    anything similar to this so I'm sorry if this has been posted and I
    didn't see it. I'm new to js, so PLEASE be patient with me! Thanks
    in advance!

    I posted the following message in a Frontpage newsgroup:
    I need to carry values from one webpage form to another. I can't use
    ..asp, I
    have to use html or dhtml. I've tried going through the VBA help
    files and i
    can't figure it out. I don't know what how to refer to the option
    button that
    was selected.

    Here's what I'm trying to do, so if there is an easier way to do it,
    PLEASE let
    me know!

    Select item (item# saved)
    Select color (item # and color ID now saved)
    Order form (info from above is already entered..only
    personal info
    needs to be entered)

    I was told to refer to a faq that gave me the following script:
    Input Page:
    <form action="myPage.html">
    BD30: <input type="radio" name="radio1" value="BD30">
    ABD30: <input type="radio" name="radio1" value="ABD30">
    <input type="submit">
    </form>

    myPage:
    <script language="JavaScript"><!--
    var passed=window.location.search.substring(1);
    alert(passed);
    //--></script>

    Technically, it works, but it creates a message box telling me
    radio1=BD30. I want it to be at the top of the page as just text (not
    a text box, which I can do, but then it can be changed). The problem
    is obviously in the myPage script, but I don't know enough yet to make
    it do what I want. What am I supposed to be doing?

    TIA again!
    Angi
     
    Angi, Nov 2, 2004
    #1
    1. Advertising

  2. Angi

    Hal Rosser Guest

    try cookies - if both pages are on the same website

    "Angi" <> wrote in message
    news:...
    > I have looked through the first 672 messages and haven't found
    > anything similar to this so I'm sorry if this has been posted and I
    > didn't see it. I'm new to js, so PLEASE be patient with me! Thanks
    > in advance!
    >
    > I posted the following message in a Frontpage newsgroup:
    > I need to carry values from one webpage form to another. I can't use
    > .asp, I
    > have to use html or dhtml. I've tried going through the VBA help
    > files and i
    > can't figure it out. I don't know what how to refer to the option
    > button that
    > was selected.
    >
    > Here's what I'm trying to do, so if there is an easier way to do it,
    > PLEASE let
    > me know!
    >
    > Select item (item# saved)
    > Select color (item # and color ID now saved)
    > Order form (info from above is already entered..only
    > personal info
    > needs to be entered)
    >
    > I was told to refer to a faq that gave me the following script:
    > Input Page:
    > <form action="myPage.html">
    > BD30: <input type="radio" name="radio1" value="BD30">
    > ABD30: <input type="radio" name="radio1" value="ABD30">
    > <input type="submit">
    > </form>
    >
    > myPage:
    > <script language="JavaScript"><!--
    > var passed=window.location.search.substring(1);
    > alert(passed);
    > //--></script>
    >
    > Technically, it works, but it creates a message box telling me
    > radio1=BD30. I want it to be at the top of the page as just text (not
    > a text box, which I can do, but then it can be changed). The problem
    > is obviously in the myPage script, but I don't know enough yet to make
    > it do what I want. What am I supposed to be doing?
    >
    > TIA again!
    > Angi



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.781 / Virus Database: 527 - Release Date: 10/22/2004
     
    Hal Rosser, Nov 2, 2004
    #2
    1. Advertising

  3. On Mon, 1 Nov 2004 23:44:28 -0500, Hal Rosser <>
    wrote:

    > try cookies - if both pages are on the same website


    [snipped quoted text]

    Was a 3KB+ post really necessary just to say that?

    Please don't top-post.

    Replies should be placed inline with the relevant quoted material.
    Unrelated material should be deleted (and preferably marked as such).

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Nov 2, 2004
    #3
  4. Angi

    Angi Guest

    "Hal Rosser" <> wrote in message news:<FeEhd.9244$>...
    > try cookies - if both pages are on the same website
    >


    Forgive me, but first of all, I don't know how to create a cookie
    (Newbie with javascript) and secondly, if a person doesn't accept
    cookies, like me, that won't work, will it?

    Also, I'm assuming you mean use a cookie to grab the values, which
    would change all my code (1st & 2nd page)...right?

    thx
     
    Angi, Nov 2, 2004
    #4
  5. On 2 Nov 2004 06:30:34 -0800, Angi <> wrote:

    > "Hal Rosser" <> wrote in message
    > news:<FeEhd.9244$>...
    >
    >> try cookies - if both pages are on the same website

    >
    > Forgive me, but first of all, I don't know how to create a cookie
    > (Newbie with javascript)


    A Google search of both the Web and this group would have produced some
    code.

    For example, kaeli, a regular poster here, as a cookie collection:
    <URL:http://www.ipwebdesign.net/kaelisSpace/useful_cookies.html>.

    > and secondly, if a person doesn't accept cookies, like me, that won't
    > work, will it?


    To be fair, relying on scripting is just as flawed as relying on cookies.
    The *only* reliable approach is to store the values on the server and
    refer to them later. However, you've ruled that out for whatever reason.

    > Also, I'm assuming you mean use a cookie to grab the values, which would
    > change all my code (1st & 2nd page)...right?


    He means save the values to a cookie, and read them back on a later page.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Nov 2, 2004
    #5
  6. Angi

    Robert Guest

    (Angi) wrote in message
    > myPage:
    > <script language="JavaScript"><!--
    > var passed=window.location.search.substring(1);
    > alert(passed);
    > //--></script>
    >
    > Technically, it works, but it creates a message box telling me
    > radio1=BD30.


    Delete the alert. You might want to change substring(1) to
    substring(8).

    > I want it to be at the top of the page as just text (not
    > a text box, which I can do, but then it can be changed). The problem
    > is obviously in the myPage script, but I don't know enough yet to make
    > it do what I want. What am I supposed to be doing?


    Do not know how you got the value in window.location.search since your
    code does not show how.

    You could use document.write to paste the string in your html file.
    Something like:

    <body>
    <p>
    <script type="text/javascript">
    document.write("Passed value is " + passed);
    </script>
    </p>
    </body>

    This will set the value when the page loads. For something to change
    after the page is loaded, you need to use innerHTHL.

    Robert
     
    Robert, Nov 2, 2004
    #6
  7. Angi

    Mick White Guest

    Angi wrote:

    > Robert,
    > Thanks for the reply. OK!! That worked...I don't understand why changing the
    > 1 to an 8 made it work, but I'll take it.
    >
    > Thanks so much!


    var passed=location.search.split("=")[1]

    Mick
     
    Mick White, Nov 3, 2004
    #7
  8. Angi

    Robert Guest

    pam (Angi) wrote in message news:<>...
    > Robert,
    > Thanks for the reply. OK!! That worked...I don't understand why changing the
    > 1 to an 8 made it work, but I'll take it.


    You could put these statements just before the variable definition:

    alert(window.location.search);
    alert("0.." + window.location.search.substring(0) + "\n" +
    "1.." + window.location.search.substring(1) + "\n" +
    "7.." + window.location.search.substring(7) + "\n" +
    "8.." + window.location.search.substring(8) );

    These statements should give you an idea of what is going on. I haven't tested them.

    > Thanks so much!


    Glad to be of assistance.

    Robert
     
    Robert, Nov 5, 2004
    #8
  9. On 03 Nov 2004 01:06:18 GMT, Angi <> wrote:

    > Mike,
    > Thank you for being gentle with the newbie!


    :)

    [snip]

    > I think you're talking about me not using .asp. My host doesn't allow
    > them so I needed to find another way to what I need to do.


    There are other server-side languages. Any one of them should suffice.

    [snip]

    > I understand the concept of a cookie, but I still don't know how to
    > refer to a form control after the window has closed.


    You can't and the idea is that you don't need to. However, the approach
    isn't appropriate in your case. I was merely pointing out what Hal was
    referring to; I didn't intend to mislead you.

    The intention was that the form values would be saved in the cookie and
    held there during the transition to the next page. Here you could read the
    values back (assuming cookies were supported).

    What you began to do - pass the values through the URL - would be best if
    server-side support isn't available. To find prepared code for parsing the
    query/search string, search the archives:
    <URL:http://groups.google.com/groups?q=group%3Acomp.lang.javascript+parse+query+%7C+search+string>.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Nov 6, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Adams

    Question about passing values?

    Ken Adams, Nov 12, 2004, in forum: Java
    Replies:
    7
    Views:
    346
  2. Chad
    Replies:
    9
    Views:
    365
    David Thompson
    Jan 7, 2010
  3. Matt
    Replies:
    1
    Views:
    149
  4. Paul
    Replies:
    1
    Views:
    100
    McKirahan
    Sep 20, 2005
  5. Replies:
    2
    Views:
    177
    Richard Cornford
    Aug 27, 2007
Loading...

Share This Page