473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Modifying form data before submission

I have a form which houses basic inputs, as well as a few multiple select
forms.

I need to parse all the 'values' which are in this multiple select form (it
gets manipulated dynamically client side). I wanted to create a function
that loops through all the form elements, and if the type 'select-multiple'
is detected, gather the VALUES of each <option> inside it.

The bit I'm stuck on is then how to reconstruct this into a form submission.
Preferably I wanted the data from the 'select-multiple' element to be
submitted as comma delimited, eg 14,12,512,63,62 which would later be parsed
by PHP.

I was considering reconstructing a query string and submitting that as GET,
but I'd prefer to POST it along with the other data (such as INPUTS etc)
which do not need to be changed.

Can I somehow attach some 'hidden' type data onto the end of the form
submission at this point?

Thanks in advance
Jul 20 '05 #1
2 4385
On Fri, 25 Jul 2003 17:43:45 +1000, "Logical" <lo***@privacy.net>
wrote:
I have a form which houses basic inputs, as well as a few multiple select
forms.

I need to parse all the 'values' which are in this multiple select form (it
gets manipulated dynamically client side). I wanted to create a function
that loops through all the form elements, and if the type 'select-multiple'
is detected, gather the VALUES of each <option> inside it.

The bit I'm stuck on is then how to reconstruct this into a form submission.
Preferably I wanted the data from the 'select-multiple' element to be
submitted as comma delimited, eg 14,12,512,63,62 which would later be parsed
by PHP.

I was considering reconstructing a query string and submitting that as GET,
but I'd prefer to POST it along with the other data (such as INPUTS etc)
which do not need to be changed.

Can I somehow attach some 'hidden' type data onto the end of the form
submission at this point?

Check the Netscape JavaScript site at http://devedge.netscape.com/
and look at the CFormData JAvaScript object.

That might do the trick for you.

Jul 20 '05 #2
First off, it's not really clear to me if you want the selected values from
a multiple select element, or just all of the values regardless of selection
state. In the case of the former (selected), you can just re-name your
multiple select element using this syntax:

<select name="manyselects[]" size="10" multiple="multiple">

That can be parsed/interpreted because it is already construed as an array
by PHP...

echo print_r($_POST['manyselects']);

In the case of the latter, you would have to implement a javascript
construct to loop through the select elements on the form before submittal
to collect the values. Perhaps something like the following...(untested)

The intention would be to get a comma separated string for all the
multiple-select option values. You could then perhaps assign that value to
a hidden form variable:
function processMultiples() {
var thisSelect;
var multiValues;
var theForm = window.document.forms[0];

for (var i = 0; i < theForm.length; i ++) {
if (theForm.elements[i].type == "select-multiple") {
thisSelect = theForm.elements[i];
for (var j = 0; j < thisSelect.length; j ++)
multiValues += thisSelect.options[j].value + ',';
}
}

// strip last comma
multiValues = multiValues.substr(0, multiValues.length - 1);

return multiValues;
}
--
HTH,
DWilliams

"Logical" <lo***@privacy.net> wrote in message
news:bf************@ID-159445.news.uni-berlin.de...
I have a form which houses basic inputs, as well as a few multiple select
forms.

I need to parse all the 'values' which are in this multiple select form (it gets manipulated dynamically client side). I wanted to create a function
that loops through all the form elements, and if the type 'select-multiple' is detected, gather the VALUES of each <option> inside it.

The bit I'm stuck on is then how to reconstruct this into a form submission. Preferably I wanted the data from the 'select-multiple' element to be
submitted as comma delimited, eg 14,12,512,63,62 which would later be parsed by PHP.

I was considering reconstructing a query string and submitting that as GET, but I'd prefer to POST it along with the other data (such as INPUTS etc)
which do not need to be changed.

Can I somehow attach some 'hidden' type data onto the end of the form
submission at this point?

Thanks in advance

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ratlhead | last post by:
Hey all, I'm attempting to do some form processing on a server that has register_globals off, however, I've run into a confusing situation and need some help. Basically, the form is a...
16
by: lawrence | last post by:
I was told in another newsgroup (about XML, I was wondering how to control user input) that most modern browsers empower the designer to cast the user created input to a particular character...
0
by: Toby Inkster | last post by:
Like me, you are probably confronted with many requests for surveys, questionnaires, feedback forms, registration forms and so forth: forms where the processing requirements are very simple (store...
8
by: yawnmoth | last post by:
Say I have the following HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <form action="">
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
6
by: tuxedo | last post by:
I have a fixed html structure, where only one form and a simple select menu will exist on an html page, as follows: <form action="order" method="POST"> <select name="dinner"> <option...
1
by: Homer | last post by:
Hi, I just got a requirement from my HR department to automate their form submission process and integrate it into the Intranet project that I had just completed Phase 1 of. Because of the...
6
by: smk17 | last post by:
I've spent the last few minutes searching for this question and I found an answer, but it wasn't quite what the client wanted. I have a simple online form where the user needs to fill out five...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.