Page 1 of 1

Attaching extra info to a form submission via Javascript

Posted: Tue Sep 05, 2006 3:12 pm
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?

Posted: Tue Sep 05, 2006 3:33 pm
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..

Posted: Tue Sep 05, 2006 3:48 pm
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?

Posted: Tue Sep 05, 2006 7:17 pm
by feyd

Code: Select all

instance = new objectName();

Posted: Tue Sep 05, 2006 11:48 pm
by Luke

Code: Select all

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

Code: Select all

onclick="functionThatCreatesAnInstance()"
?

Posted: Wed Sep 06, 2006 11:48 am
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...