473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to pass a variable from javascript to another ASP page

11
Hi,

I have a code like this in my first asp form

function something()
{
if (confirm("do you want to continue")==true)

{
a=1
}
else
{
a=0
}
}
now i want to make use of my variable a in my second asp form. Please guide me to get it.

Thanks.
May 15 '07 #1
5 2676
jhardman
3,406 Expert 2GB
Deedi,

You are going to have to pass it as either form data
[html]<input type="hidden" name="a" value="1">[/html]
or as querystring
[html]<a href="secondPage.asp?a=1">continue</a>[/html]
Either one will require the use of javascript to put the data there. You might also be able to put it into a cookie. Can javascript set cookies? I don't know.

Anyway, javascript is required regardless.

Jared
May 15 '07 #2
deedi
11
Hi Jared,

I've tried with the hidden variable , but it doesn't work. When i type document.form1. the hidden varable name is not coming here. So i couldn't proceed in that way.

The query string method worked well, however. Thanks for your answer.
May 25 '07 #3
but through query string the value of variable will be shown to user through url.

what will u do if u don't want to show the value to the user......

document.form1.hiddenvalriable.value=a;
will work. this name will not come automatically, u have to write.
May 25 '07 #4
deedi
11
Hi Dipti,


I've created a hidden variable as said above. But it is not reflecting when i want to use that. Don't know what is the mistake...
May 29 '07 #5
jhardman
3,406 Expert 2GB
For form data to be passed to the next page, a form needs to be submitted. For example, I wrote this code to post the screen resolution to the next page. When the page loads it adds the info I wanted to hidden inputs (but this would work just as well with any input type) and then submits the form.
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <script language="JavaScript">
  3. <!-- Begin
  4. function rP(inH, inW, frm) {
  5.    inH.value=screen.height;
  6.    inW.value=screen.width;
  7.    frm.submit();
  8. }
  9. // END -->
  10. </script>
  11. </head>
  12. <body onload="rP(this.document.all.bob.height,
  13.  this.document.all.bob.width,
  14.  this.document.all.bob)">
  15. <form name="bob" action="test2.asp" method="post">
  16. <input type="hidden" name="height">
  17. <input type="hidden" name="width">
  18. </form>
  19.  
Is this similar to what you wanted to try?

Jared
May 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Seeker | last post by:
Newbie question here... I have a form with some radio buttons. To verify that at least one of the buttons was chosen I use the following code ("f" is my form object) : var btnChosen; for...
1
by: carmen | last post by:
I am using the code below to open another page depending on what is selected. This is working ok but I would like to streamline it so that I will hot have to create a page everytime a new category...
7
by: olga | last post by:
Hi, On my site, i want to pass a javascript variable to php. I know that this needs to done in a link or in a post. I want to know if there is a way i can do it with an html link. I should...
2
by: Shabam | last post by:
I need to have a static html page basically pass all GET arguments from one page to another. For example, I'm on page A. It has "x=12&y=45". There's a link on page A that goes to page B. Page B...
2
by: Augusto Cesar | last post by:
Hello people. How can I Pass ASP Array variable to Javascript; I´m to trying this: <script language="JavaScript"> var x = new Array(10);
8
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable,...
17
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
2
by: =?Utf-8?B?TWlrZQ==?= | last post by:
I don't think this is possible, but here goes. I have a webform containing a javascript method. The javascript method is fired when the page loads and it populates some client-side input...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.