Attaching extra info to a form submission via Javascript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Attaching extra info to a form submission via Javascript

Post by Luke »

What is the best way to attach information to a form submission via javascript. I have a form that requests latitude/longitude coordinates when you enter in an address (AJAX). I would like for that information to be attached to the form before the user hits submit (like a hidden field). How could I do this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Through the DOM. document.createElement('INPUT') yadda yadda..

I posted example usage of createElement() a while ago, if you need to know more..
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

thanks feyd... that's exactly what i was looking for :D

Another question. I am building my first real javascript object. It will be created via the click of a button. I am kind of confused about how objects work in javascript... how would I create an instance of an object by clicking on a button?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

instance = new objectName();
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Code: Select all

onclick="instance = new objectName();"
?

Code: Select all

onclick="functionThatCreatesAnInstance()"
?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

both approach differ in the way you code... in first you instantiate it then & there... in second you delegate it to a function.. thatsall...
Post Reply