p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   HTML Code Clinic (http://p2p.wrox.com/forumdisplay.php?f=90)
-   -   Straight HTML code passing variables from one page to another... (http://p2p.wrox.com/showthread.php?t=79814)

RinoDM June 18th, 2010 02:29 PM

Straight HTML code passing variables from one page to another...
Hi to all....

i'm creating straight HTML pages since this laptop will have no internet and so on...
user will enter data on one page, pass it to the next page and print...

i've beening using javascript asp pages passing variables from one page to another...
with NO problems...ex.:
varName= QueryString("Name")

how would i do this with straight HTML...

Thanking you in advance...


Old Pedant June 18th, 2010 04:15 PM

Use JavaScript to create the equivalent collection for use by other JS code:

<script type="text/javascript">
var querystring = [ ];
var qs = location.search;
if ( qs.length > 1 )
    qs = qs.substring(1); // skip past the ?
    var pairs = qs.split( /\&/g ); // get all the name=value pairst
    for ( var p = 0; p < pairs.length )
        var pair = pairs[p];
        querystring[ pair[0] ] = unescape( pair[1].replace(/\+/g," ");

Then, anyplace in your page where in ASP code you might use

    var foo = Request.QueryString("foo");
you instead simply do

    var foo = querystring["foo"];
CAUTION: "foo" will be case sensitive, unlike in ASP. If you wish, you could replace

        querystring[ pair[0] ] = unescape( pair[1].replace(/\+/g," ");
        querystring[ pair[0].toLowerCase() ] = unescape( pair[1].replace(/\+/g," ");

and then always use lower case names ("foo" in place of "Foo" or "FOO") when finding values.

Untested, though I have used this same code before. If there's a goof, it's just a typo.

Old Pedant June 18th, 2010 04:16 PM

And of course all your Response.Write's become document.write( ). And other considerations. But you get the idea.

chroniclemaster1 June 19th, 2010 01:40 PM

XHTML is part of the front-end developer's holy trinity: XHTML, CSS, Javascript. XHTML handles the primary document structure of XHTML elements. CSS handles page appearance. Javascript handles page behavior.

The boundaries are a little slippery but basically that's the difference; so if you want to work with variables like in a server side language, the structure of XHTML elements can't do that. You need Javascript, which is why Old Pedant has put together this beautifully designed script.

RinoDM June 21st, 2010 03:24 PM

Thank you for your re-ply...

maybe i should have asked this question from the beginning...

the reason why i asked is because on my laptop "notebook" home edition which does not come with iis... my pages i created are .asp but when i open them up in browser it opens up the code instead... how can i view the page instead of the code???

chroniclemaster1 June 21st, 2010 03:59 PM

Ahhhh... OK, that does explain your situation much better.

XHTML, CSS, and Javascript all work in a browser. You can use them freely.

Most everything else, ASP, .NET, PHP, Java, etc. are server-side languages. That's why your ASP files are producing code instead of the actual web page you want. The .asp file is a mix of XHTML and your ASP code. However, your .asp files needs some kind of processor to read your ASP code, react to it, and render the appropriate XHTML-only document which it then sends to the user's browser (in this case... You!)

Server side processors are pre-installed or you have to manually install them so the server knows how to interpret the code you're passing to it. Since you don't have IIS, a standard server-side processor isn't going to work, because there's no server to make use of it when you try to access a page.

I would say your best bet is to download Visual Studio 2010 Express. It has a development server that corresponds very well to IIS (as in, I can't remember a discrepancy between my development and production server in the five years I've been programming). You start up one of your applications and it allows you to work in code and test the results live. It's a feature called edit and continue, but you'll just care that it reduces your risk as you program your modules. That being said, I've never tried to use it with ASP files. As long as an ASP processor is installed on your computer, I think it should work. (for all I know, it's probably built into windows or the .NET framework).

The flip side is that ASP is definitely not a current generation technology, so if you haven't started programming in .NET already, this might be the perfect time to jump into C#.

Old Pedant June 22nd, 2010 06:10 PM

Actually, you can't run ASP on some versions of Windows. For the simple reason that ASP in turn requires the IIS web server and MicroSlop just decided to deny it to "home" users. I know you can't do it with XP Home Edition and I don't believe you can do it with Vista Home Basic.

This also means you can't run ASP.NET pages on those systems using IIS. But you *can* still develop ASP.NET on them, because Visual Studio (even the free Express editions) includes a built-in mini-web-server (which is only capable of serving up HTML and ASP.NET pages).

But running an application "under" Visual Studio is not something you would ordinarily want to do. Okay if it's only for your own use, but surely you wouldn't give that to anybody else (among other things, any silly slip-up by them could do untold damage to your files).

In practice, if you want to use ASP or ASP.NET pages via http://localhost you need to install IIS. And that means you need to upgrade from the Home Edition to the next step up. (WIndows Vista Home Premium, for example, is what I use for both ASP and ASP.NET and yes, it includes a [somewhat limited] version of IIS.)

Failing all this, you could install an Apache web server on virtually any operating system and run PHP pages. Or install Tomcat and run JSP. Only MicroSquish knows why they think home users don't deserve even a miniature web server.

chroniclemaster1 June 22nd, 2010 06:53 PM

Interesting, that's good to know since I've never worked with ASP.

RinoDM, everything Old Pedant said is true; though the mini-server in the express editions of VS is just fine for development and then you can deploy your site to a producation server. As long as you have access to a .NET enabled hosting account, even shared hosting is usually fine (just check to see if you have access to your email accounts from the application (including backend credentials) and what database options you have available.

Old Pedant June 22nd, 2010 07:39 PM

But that doesn't help him.

See his first post:

i'm creating straight HTML pages since this laptop will have no internet and so on...
user will enter data on one page, pass it to the next page and print...
Quite frankly, even though it may mean some rewriting, I can't see why you couldn't/wouldn't use the technique I showed: Replace the ASP code with ordinary client-side JS scripting. Oh, there will be other changes, but if the ASP code isn't very complex you should be able to make it all work.

All times are GMT -4. The time now is 09:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.