473,387 Members | 1,495 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,387 software developers and data experts.

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 1527
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.length-1;
for(var i = 0; i < numberElements; i++) {
queryString+=frm.elements[i].name
+"="+encodeURIComponent(frm.elements[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...@web.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.length-1;
for(var i = 0; i < numberElements; i++) {
queryString+=frm.elements[i].name
+"="+encodeURIComponent(frm.elements[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.length;

for(var i=0; i<numberElements; i++) {
element = frm.elements[i];
if (element.name && element.name != '') {
queryString.push(element.name + "="
+ encodeURIComponent(element.value));
}
}
return queryString.join('&'); }
}
--
Rob

Sep 3 '07 #4

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

Similar topics

2
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...
10
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...
2
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>...
3
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...
1
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...
38
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. ...
2
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...
7
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 :...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.