PDA

View Full Version : Form submit problems


Horus_Kol
09-08-2006, 08:41 AM
I need to do a little pre-processing on some form data before sending it to the server, so I have an onclick event on my "send" button which calls the following function:


function support_email_submit()
{
var email_list_target_options = document.forms[0].email_list_target.options;
for (i = 0; i < email_list_target_options.length; i++)
{
email_list_target_options[i].selected = true;
}

document.forms[0].submit();
}


however, I get an error on the submit() - it says it is not a function...

it doesn't work when I use the form's name, either...

any ideas?

RysChwith
09-08-2006, 01:19 PM
You could use the onsubmit handler of the form, rather than the onclick of the button. Then it'd just submit automatically once the function is finished.

Rys

blackpepper
09-08-2006, 08:39 PM
sry if im totally off here but just trying to helpout:)
should it be this.
function support_email_submit()
{
var email_list_target_options = document.forms[0].email_list_target.options;
for (i = 0; i < email_list_target_options.length; i++)
{
document.forms[0].[i].options[ document.forms[0].[i].selectedIndex ].value = 'true';
}

document.forms[0].submit();

}
or did i misunderstand/misread/not get your original code:confused: good luck
i probley misread your code or dont get it, but i thought you were reading list values, and thats the way i usually do it,, if so id try replacing them through out. lol that may be totally wrong:crying:

Horus_Kol
09-11-2006, 03:43 AM
Rys - hmm.. okay, I'll give that a go...

blackpepper, the whole point of:
var email_list_target_options = document.forms[0].email_list_target.options;
is so that you can use email_list_target_options as an alias for the options array of a select instead of having to write the whole thing out again and again through your script.

Horus_Kol
09-11-2006, 03:46 AM
okay - it submits :) thanks

Horus_Kol
09-11-2006, 04:18 AM
moving on...
now, my list of selected emails is not being submitted.

I have a select box on one side of the form ("email_list_full") with all names of registered intranet users, and a second select ("email_list_target") with the names of the intended recipients.

I use javascript to move select addresses from the full list into the target list...

but when I submit the form, I don't see the second select ("email_list_target") in my POST array...

I have attached the HTML page (slightly edited - no real names and so on).

Thanks in advance

_Aerospace_Eng_
09-12-2006, 02:58 AM
Your whole script seems to be erroring out. I'm wondering why you are using the brackets for your calls to your ids and names.
emails[email_selected_idx]['id']
It seems like you think the ids are in some type of array.

Horus_Kol
09-12-2006, 09:02 AM
hmmm... seems I uploaded the wrong file - sorry...

This one should do it