Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > passing values Newbie question

Reply
Thread Tools

passing values Newbie question

 
 
Angi
Guest
Posts: n/a
 
      11-02-2004
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
 
Reply With Quote
 
 
 
 
Hal Rosser
Guest
Posts: n/a
 
      11-02-2004
try cookies - if both pages are on the same website

"Angi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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


 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      11-02-2004
On Mon, 1 Nov 2004 23:44:28 -0500, Hal Rosser <(E-Mail Removed)>
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.
 
Reply With Quote
 
Angi
Guest
Posts: n/a
 
      11-02-2004
"Hal Rosser" <(E-Mail Removed)> wrote in message news:<FeEhd.9244$(E-Mail Removed)>. ..
> 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
 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      11-02-2004
On 2 Nov 2004 06:30:34 -0800, Angi <(E-Mail Removed)> wrote:

> "Hal Rosser" <(E-Mail Removed)> wrote in message
> news:<FeEhd.9244$(E-Mail Removed)>. ..
>
>> 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.
 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      11-02-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (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(.

> 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
 
Reply With Quote
 
Mick White
Guest
Posts: n/a
 
      11-03-2004
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
 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      11-05-2004
(E-Mail Removed)pam (Angi) wrote in message news:<(E-Mail Removed)>...
> 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( );

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
 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      11-06-2004
On 03 Nov 2004 01:06:18 GMT, Angi <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A question about passing values to a function. Chad C Programming 9 01-07-2010 09:17 AM
Passing values between parent and child windows - Beginner question evrimagha@hotmail.com Javascript 2 08-27-2007 05:42 PM
Easy question. about passing values Paul Javascript 1 09-20-2005 10:49 PM
Question about passing values? Ken Adams Java 7 11-13-2004 11:59 PM
Newbie needs help! Passing select values to hidden text field... Matt Javascript 1 07-21-2004 01:49 AM



Advertisments