Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 09-02-2012, 11:59 AM   #1 (permalink)
Alpha Geek
 
mohityadavx's Avatar
 
Join Date: Nov 2010
Location: Gurgaon (Delhi NCR)
Posts: 574
Default javascript pass variable next page


Well i am having a problem.

i have made a form and on clicking the submit button, javascript validation is done to check all fields are correctly filled or not. Now the problem is I want to use these entered variables so the only way remains is redirect the page to next page after clicking submit using "action = page.html" tag.

So how can i pass these variable to next page. I cant use PHP but javascript (Its kind of a constraint on me )

Well what i want is this site Kagzaat - Free Legal Online Documentation( www.kagzaat.com) to be in javascript instead of PHP . Please help.


if any other way exist please tell.
__________________
XPS 15 | Infibeam Pi |LG P500 |GoGear SA52XX | Sony PS2 | Sony H55 | Sennheiser CX 180 , MX760

For Free Legal Documentation - Rent Agreement/RTI etc
KAGZAAT
www.bleedlaw.com For Law student & aspirant
mohityadavx is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 09-02-2012, 02:34 PM   #2 (permalink)
Right Off the Assembly Line
 
Join Date: Feb 2012
Posts: 1
Default Re: javascript pass variable next page

Try Javascript Sessions or javascript cookies..
this might get you started
Cookie-less Session Variables in JavaScript » SitePoint
How to save session values in JavaScript - JavaScript / DHTML / AJAX | DaniWeb
Abhinav1217 is offline   Reply With Quote
Old 09-02-2012, 03:54 PM   #3 (permalink)
Rubik's Uncle!!
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,783
Default Re: javascript pass variable next page

you can use two kinds of approach.
1. use global JS variables, include the variables in a JS file and refer those files in both the pages.
Ex: create test.js

Code:
// filename.js
var test1;
var test2;
then refer this JS file in both the pages.

in the first page, set the variables after your validation.

in the second page retrieve the values from the variable.

2. use Query string(this is better and easy).

query strings are the name value pairs which are passed in the url itself.

eg: _http://test.com/submitpage.html?key1=value1&key2=value2

here is a sample for accessing query strings using Javascripts.

Code:
var qsParm = new Array();
function qs() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
}
}
}
Source for #2
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps @75GB FUP :)
Battlefield 3 Multiplayer Discussion | Battlefield 3 Low Latency Servers List
Charan is offline   Reply With Quote
Old 09-02-2012, 04:48 PM   #4 (permalink)
Alpha Geek
 
mohityadavx's Avatar
 
Join Date: Nov 2010
Location: Gurgaon (Delhi NCR)
Posts: 574
Default Re: javascript pass variable next page

Thanx
__________________
XPS 15 | Infibeam Pi |LG P500 |GoGear SA52XX | Sony PS2 | Sony H55 | Sennheiser CX 180 , MX760

For Free Legal Documentation - Rent Agreement/RTI etc
KAGZAAT
www.bleedlaw.com For Law student & aspirant
mohityadavx is offline   Reply With Quote
Old 10-02-2012, 10:38 AM   #5 (permalink)
Fullbring
 
Zangetsu's Avatar
 
Join Date: Jan 2008
Location: Soul Society
Posts: 5,523
Default Re: javascript pass variable next page

I recommend using query strings
__________________
I'm the One you've been Waiting for...
Zangetsu is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:39 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2