Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 12th, 2007, 11:12 AM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Grabbing form variables

I have a form on my page that I'd like to copy the entry in it before it's submitted.

For example: In box "city", I'd like to copy that to a variable called "cityname" to use elsewhere in the programming. (The variable isn't passed from page to page and in this case, I don't want it to be as "city"."

Is there any way to do this before the form's submitted?

Thanks in advance.
 
Old June 12th, 2007, 03:48 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You can get the value via Javascript and using AJAX do some further processing with it, but that value will not become available to your script until the form has been submitted otherwise.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old June 14th, 2007, 01:04 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Any suggestions on where I could find something like this in JavaScript? Thanks!

 
Old June 14th, 2007, 06:49 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Getting the value in Javascript is easy:

var City = myForm.elements["txtCity"].value;

The ajax is a bit more tricky and i suggest you go read some primers on it but, in any event, the most you are going to be able to do with Ajax is get the value of your text box, send that value to another page on the server, have some sort of processing done and a value returned to your Ajax script were you can change the host page.

I am not sure if that is what you are looking for or not.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old June 18th, 2007, 04:23 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Let me see if I can be a little more specific. Right now I have a form that I'm submitting via .asp "post" to an off-site server. Before the form's posted, I want to copy the information in the "city" box pre-submission or at the same time the form's submitted to the "cityName" variable. (All this info goes to a remote server and they return everything variable-wise except this one variable...which I need to process my end of things. Asking them to add things is a nightmare.)

Will the: var City = myForm.elements["txtCity"].value; command work for that?

Thanks!
 
Old June 18th, 2007, 05:08 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

That will get the value of txtCity, you can either do it at submit time or you can wire up the onBlur event of the text box to populate it pre-submittal.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables from 1 form to another. jainin_shah9 C# 10 February 18th, 2008 07:59 PM
Grabbing Value From Textbox in subform bph Access 20 March 15th, 2005 05:29 PM
Form Variables interrupt Javascript How-To 3 June 29th, 2004 07:00 AM
Grabbing URL aingalsbe PHP How-To 1 April 5th, 2004 05:01 PM





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