473,659 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

order of form elements

I have a form with a dropdown (select) menu a text input field and
some hidden values, along with an input botton that triggers an ajax
function that submits the form.
If the button is after the select statement, the chosen value of the
selection of the dropdown is posted. But if the button is before the
select statement, everything in the form is posted but the value of
the selection

Why would the select box be left out of the post ?

Sep 2 '07 #1
3 1547
gr*****@reenie. org wrote:
I have a form with a dropdown (select) menu a text input field and
some hidden values, along with an input botton that triggers an ajax
function that submits the form.
It would have been wise to post that function.
If the button is after the select statement,
There are no statements in the (eXtensible) HyperText *Markup Language*.
You mean a `select' _element_.
the chosen value of the selection of the dropdown is posted. But if
the button is before the select statement, everything in the form is
posted but the value of the selection

Why would the select box be left out of the post ?
As you have not provided enough information, I have to make an educated
guess: your "ajax function" iterates through the form elements collection
(where the numeric index of an element is defined by the arrangement of
the controls in the markup) until it finds the submit button, i.e. an
element of type "submit". That algorithm should be modified.
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Sep 2 '07 #2
No, but close. I knew where the form iteration occured and when I
looked at it it was like this:

var numberElements = frm.elements.le ngth-1;
for(var i = 0; i < numberElements; i++) {
queryString+=fr m.elements[i].name
+"="+encodeURIC omponent(frm.el ements[i].value);
if(i < numberElements-1) queryString+="& ";
}

So for some reason, it was written to always skip the last element. I
took out the -1 from "length-1" and it works as expected now. Thanks,
you really helped.
On Sep 2, 5:20 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
grou...@reenie. org wrote:
I have a form with a dropdown (select) menu a text input field and
some hidden values, along with an input botton that triggers an ajax
function that submits the form.

It would have been wise to post that function.
If the button is after the select statement,

There are no statements in the (eXtensible) HyperText *Markup Language*.
You mean a `select' _element_.
the chosen value of the selection of the dropdown is posted. But if
the button is before the select statement, everything in the form is
posted but the value of the selection
Why would the select box be left out of the post ?

As you have not provided enough information, I have to make an educated
guess: your "ajax function" iterates through the form elements collection
(where the numeric index of an element is defined by the arrangement of
the controls in the markup) until it finds the submit button, i.e. an
element of type "submit". That algorithm should be modified.

PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>

Sep 2 '07 #3
On Sep 3, 8:12 am, grou...@reenie. org wrote:
No,
Please don't top post, reply below trimmed quotes.

but close. I knew where the form iteration occured and when I
looked at it it was like this:

var numberElements = frm.elements.le ngth-1;
for(var i = 0; i < numberElements; i++) {
queryString+=fr m.elements[i].name
+"="+encodeURIC omponent(frm.el ements[i].value);
if(i < numberElements-1) queryString+="& ";
}

So for some reason, it was written to always skip the last element. I
took out the -1 from "length-1" and it works as expected now. Thanks,
you really helped.
You should also only return controls that have a value for the name
attribute, and do not expect select elements to return their value in
all browsers (though likely those that don't aren't supported by your
"AJAX" form anyway).

You might also consider using an array to join the value/name pairs
with '&', something like:

function ... ()
{
var element, queryString = [];
var numberElements = frm.elements.le ngth;

for(var i=0; i<numberElement s; i++) {
element = frm.elements[i];
if (element.name && element.name != '') {
queryString.pus h(element.name + "="
+ encodeURICompon ent(element.val ue));
}
}
return queryString.joi n('&'); }
}
--
Rob

Sep 3 '07 #4

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

Similar topics

2
1501
by: Bob Lehmann | last post by:
I know that the order of from fields from a form post are somewhat random. But, what about fields that have the same name - <input type="text" name="something" value=""> First Choice <input type="text" name="something" value=""> Second Choice <input type="text" name="something" value=""> Third Choice <input type="text" name="something" value=""> Fourth Choice First = "bananna" Second = "orange"
10
3642
by: Mark C. Neustadt | last post by:
Okay, okay... from what I can find, I'm gonna be out of luck. I also understand that it *shouldn't* matter but it does. I'm trying to send some XML to Amazon and they're requiring the nodes to be in a specific order. I am supposed to send the elements in the following order:AmazonOrderID, MerchantOrderID, StatusCode and then a collection of Item elements. When I serialize my object, the XML is putting the StatusCode element after the...
2
2301
by: Daniel Lidström | last post by:
Hi, I would like to know the cleanest way to change the serialization of my Line class from: <Line staStart="2327.02" length="10.00000003390744"> <End>549016.570965 57945.741122</End> <Start>549019.590988 57955.274194</Start> </Line>
3
7085
by: Charles | last post by:
I am trying to add the ability for a user to change the order in which the elements are listed in a dropdown list box. Before I added the ListID field the dropdown list box order was controlled using the MotorhomeID. The problem I am having is that I don't know the best method for allowing people to make the ListID changes easily. Database: MS Access 2000 Table: Default-Motorhome Fields:
1
1908
by: webguy262 | last post by:
I'm trying to modify this script... <script language="JavaScript" type="text/javascript"> <!-- /* This script is Copyright (c) Paul McFedries and Logophilia Limited (http://www.mcfedries.com/). Permission is granted to use this script as long as this Copyright notice remains in place.*/
38
10155
by: ssg31415926 | last post by:
I need to compare two string arrays defined as string such that the two arrays are equal if the contents of the two are the same, where order doesn't matter and every element must be unique. E.g. these two arrays would test as equal: servers = "Admin" servers = "Finance" servers = "Payroll" servers = "Sales"
2
1902
by: libsfan01 | last post by:
hi all im looking for help on how you can track the order of elements in a parent div when these elements are dragable (with scriptaculous)? I tihnk i need to write a function that is called everytime i drag something, that works out the order of elements in a div. can anyone help me with this? how would i iterate over the child elements of a div retrieving their id's in an array.
7
2517
by: psbasha | last post by:
Hi, In case of the 'dict',the stored elements will not be in a order.It will be randomly arranged ( not as list,in list the elements will be arranged in order as we store it). For Example : --------------------- Input : Elements stored in order >>> d = {1:,100:,2:} output ( Not as expected): Order of the dict Elements as we stored has been changed >>> d
0
8341
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8539
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.