View Full Version : Need a little help in VBScript
ericjosepi
04-17-2008, 03:21 AM
Well... it's project time again and this time, I need some help. I'm trying to write a program that can shift variables between web pages using VBScript (it's the assignment parameters... I would kill to do this in an ACTUAL programming language at this late stage but regardless). I've been looking into cookies as a method for this.
The thing is, I want the user to input data into a text box, hit a submit button and store it to be called at the end of all this to be put into an outfile. Am I crazy to want to do this? There's another hitch... I want to carry the values of another form to the same outfile at the end of this.
Anyone got some tips or am I straight up boned on this?
slonkak
04-17-2008, 12:36 PM
I may be missing your point, but I'll give it a shot...
You can have a form on one page with some text fields. When the user clicks submit, it POSTS those to a second page. That page reads the POST and stores the information in hidden INPUT elements, so the user can enter more stuff on the second page without realizing the stuff from the first page is even there. If you need a third page, you can do the same thing. The third page will read the POST, which now contains all information from page 1 and 2, and when the user clicks submit, you can write your outfile.
Doing it this way eliminated the need for cookies or any kind of persistence, because you're faking the persistence with the hidden INPUT elements.
If you'd like an example, I'd be more than happy to type something up.
tnvwboy
04-17-2008, 01:42 PM
It can be done for sure. It's been too long since I've done it to remember HOW it's done but I've done it myself. I had a form that would output into a database AND then email that same data to a specific email address.
ericjosepi
04-17-2008, 06:47 PM
I may be missing your point, but I'll give it a shot...
You can have a form on one page with some text fields. When the user clicks submit, it POSTS those to a second page. That page reads the POST and stores the information in hidden INPUT elements, so the user can enter more stuff on the second page without realizing the stuff from the first page is even there. If you need a third page, you can do the same thing. The third page will read the POST, which now contains all information from page 1 and 2, and when the user clicks submit, you can write your outfile.
Doing it this way eliminated the need for cookies or any kind of persistence, because you're faking the persistence with the hidden INPUT elements.
If you'd like an example, I'd be more than happy to type something up.
Can it be done without any sort of back ground, because if so, I'd love to see an example.
slonkak
04-18-2008, 12:09 AM
Can it be done without any sort of back ground, because if so, I'd love to see an example.
Sure, it shouldn't be too difficult. I assume that when you speak of VBScript in a webpage that you are speaking of classic ASP. Since I've never written in classic ASP, I'll write it in PHP. The differences will be minor, you'll have to google for how to declare variables, read the POST, etc. in ASP.
page1.php
<html>
<head>
<title>page 1</title>
</head>
<body>
<form method="post" action="page2.php">
<input type="text" name="page1field1" />
<input type="text" name="page1field2" />
<input type="text" name="page1field3" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
The above page has 3 text fields and a Submit button that will POST those values to page2.php.
page2.php
<?php
// Grab the variables that were POSTed from the previous page
$page1field1 = $_POST['page1field1'];
$page1field2 = $_POST['page1field2'];
$page1field3 = $_POST['page1field3'];
?>
<html>
<head>
<title>page 2</title>
</head>
<body>
<form method="post" action="page3.php">
<input type="text" name="page2field1" />
<input type="text" name="page2field2" />
<input type="text" name="page2field3" />
<input type="hidden" name="page1field1" value="<?php echo $page1field1; ?>" />
<input type="hidden" name="page1field2" value="<?php echo $page1field2; ?>" />
<input type="hidden" name="page1field3" value="<?php echo $page1field3; ?>" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
You can see that page2.php now has information from both pages, though the user still only sees the 3 text boxes for the page2 input.
page3.php
<?php
// Grab the variables that were POSTed from the previous page
// Notice how everything was rePOSTed
$page1field1 = $_POST['page1field1'];
$page1field2 = $_POST['page1field2'];
$page1field3 = $_POST['page1field3'];
$page2field1 = $_POST['page2field1'];
$page2field2 = $_POST['page2field2'];
$page2field3 = $_POST['page2field3'];
?>
<html>
<head>
<title>page 3</title>
</head>
<body>
<form method="post" action="createfile.php">
<input type="text" name="page3field1" />
<input type="text" name="page3field2" />
<input type="text" name="page3field3" />
<input type="hidden" name="page1field1" value="<?php echo $page1field1; ?>" />
<input type="hidden" name="page1field2" value="<?php echo $page1field2; ?>" />
<input type="hidden" name="page1field3" value="<?php echo $page1field3; ?>" />
<input type="hidden" name="page2field1" value="<?php echo $page2field1; ?>" />
<input type="hidden" name="page2field2" value="<?php echo $page2field2; ?>" />
<input type="hidden" name="page2field3" value="<?php echo $page2field3; ?>" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
createfile.php
<?php
// Still gotta get everything from POST
$page1field1 = $_POST['page1field1'];
$page1field2 = $_POST['page1field2'];
$page1field3 = $_POST['page1field3'];
$page2field1 = $_POST['page2field1'];
$page2field2 = $_POST['page2field2'];
$page2field3 = $_POST['page2field3'];
$page3field1 = $_POST['page3field1'];
$page3field2 = $_POST['page3feld2'];
$page3field3 = $_POST['page3field3'];
// Now that you have everything in variables, write your code to spit it out to a file
?>
So that's how it's done in PHP. If you have any trouble converting that into ASP (VBScript), let me know and I'll try to help you out.
computoman
04-18-2008, 02:19 AM
Its not pretty, but it does work.
ericjosepi
04-18-2008, 06:34 AM
looks good man and thanks for the help :) I'll hopefully be able to take some of that and work it for me http://revision3.com/forum/images/icons/icon14.gif
Thanks again :D
slonkak
04-18-2008, 02:39 PM
looks good man and thanks for the help :) I'll hopefully be able to take some of that and work it for me http://revision3.com/forum/images/icons/icon14.gif
Thanks again :D
No problem. Glad to help out. If you run into any more snags, let me know.
ericjosepi
04-27-2008, 07:02 PM
No problem. Glad to help out. If you run into any more snags, let me know.
Everything went off without a hitch man. We got more than 100% on it :D
slonkak
04-27-2008, 08:26 PM
Everything went off without a hitch man. We got more than 100% on it :D
Awesome. Congrats!
rabidbadger
04-27-2008, 08:59 PM
of all people, you, Eric are not publically allowed to say "Anyone got some tips or am I straight up boned on this?"