Sending data in a DOM table to the server (with a POST)
From: milkyway (d0mufasa_at_hotmail.com)
Date: 12/29/04
- Next message: Andrew Thompson: "Re: indexed property for array does not see my bean :-("
- Previous message: Ryan Stewart: "Re: indexed property for array does not see my bean :-("
- Next in thread: Josh Martin: "Re: Sending data in a DOM table to the server (with a POST)"
- Reply: Josh Martin: "Re: Sending data in a DOM table to the server (with a POST)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Dec 2004 22:00:15 -0800
Hello all,
I am looking the best way in which one might send data sitting in a DOM
to the server. I have searched the net and found the following
approach:
------------------------ START FOUND ON NET ---------------
Re: Sending Large Data to the Server
Glenn Wearen
Wed, 05 Sep 2001 08:34:03 -0700
Two ways spring to mind
1. put HTML hidden input fields in each cell containing a duplicate of
the
cell display
put the table in a form, when the form is submitted, you should
receive
all the data from the table
2. use javascript to access the table data using DOM, dynamically
create
hidden INPUT fields on a FORM inside a hidden LAYER, submit the form
when
populated
---------------------END FOUND ON NET ----------------------
Is this the standard way of sending data to the server? When looking
around some more, also found the following:
---------------------START FOUND ON NET --------------------
If you're using a relatively new browser (IE 5.5+, Netscape 6+, Opera
7+),
you could create hidden elements on the second form to hold the values
from the first:
<form name="form1">
<input type="hidden" name="a" value="1">
<input type="hidden" name="b" value="2">
<input type="hidden" name="c" value="3">
</form>
<form name="form2">
<input type="button" value="Submit" onclick="go();">
</form>
<script>
function go() {
var f1 = document.forms['form1'];
var f2 = document.forms['form2'];
var inp;
for (var i = 0; i < f1.elements.length; i++) {
inp = document.createElement('input');
inp.setAttribute('type', 'hidden');
inp.setAttribute('name', f1.elements[i].name);
inp.setAttribute('value', f1.elements[i].value);
f2.appendChild(inp);
}
f2.submit();
}
</script>
Better yet, I'd probably write out hidden inputs in the second form so
I
could just copy the values directly across:
for (var i = 0; i < f1.elements.length; i++) {
f2.elements[f1.elements[i].name].value = f1.elements[i].value;
}
Or, target the first form to a hidden frame or new window and submit it
separately (although then the two forms may arrive at the server out of
order):
<form name="form1" target="form1" action="whatever.php4">
<script>
var f1 = document.forms['form1'];
var f2 = document.forms['form2'];
var w = window.open(f1.action, f1.target, 'width=100,height=100');
f1.submit();
f2.submit();
</script>
--------------------- END FOUND ON NET -------------------
In the case above, would one use something like:
"request.getName"
to retrieve the data out on the server side? Is there any documentation
out there that would point one into the right direction as to how to
handle these cases?
TIA for all help :-)
- Next message: Andrew Thompson: "Re: indexed property for array does not see my bean :-("
- Previous message: Ryan Stewart: "Re: indexed property for array does not see my bean :-("
- Next in thread: Josh Martin: "Re: Sending data in a DOM table to the server (with a POST)"
- Reply: Josh Martin: "Re: Sending data in a DOM table to the server (with a POST)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]