View Full Version : Checking which form submitting data

03-04-2003, 09:17 PM

I am working on a script that changes the price of soap based on additions. I got some great help with that but now I need a way to find out which form is calling the script as the prices differ from form to form.

Any help is appreciated!


03-05-2003, 12:40 AM
how are you calling the script?

03-05-2003, 01:01 AM
This is the code in the select statement to call the script:


This is the function being called:

function newMsg(objSelect)

I am just wondering - would this work if I called the script from "onSubmit"? That way it would not have to worry about which form it was although it may not be able to give me the value chosen in the select (the reason the script is called from the select statement.)


03-05-2003, 01:05 AM
You can get the form object that contains the element the function was called from like this:

function newMsg(objSelect) {
var objForm = objSelect.form;

All form elements have a .form property for just this purpose.

btw you can pretty much get any data about the current document from anywhere...

03-05-2003, 01:12 AM
When I use the code:

var objForm = objSelect.form;

the alert box comes up with [object]

Can you help some more? Also, I would love to find out how you can reference anything from anywhere - my shopping cart uses a product[] field making things a little tricky.


03-05-2003, 01:20 AM
It's not an error; that's your form object! Your original question was in re "I need a way to find out which form is calling the script..." Now that you've got the object, you can read any of its properties easily. Hard to say more as you haven't explained what it is you'd like to do, or how your data is structured.

You'd reference that product[] field the same way:


My remark about referencing was just a reassurance - lots of people just getting familiar with client-side programming spend considerable time worrying "is this/that/the other possible?". These days, these browsers, it almost always is - within the constraints that limit web pages, naturally.

03-05-2003, 01:45 AM
I did upload my page to the following URL if you are interested in looking at the coding (it is not the "working" version):


Thanks again,

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum