...

View Full Version : data from forms



looka
10-12-2005, 09:54 PM
is there any easy way to get data from a form?
(so called datastream i guess)


now im using this script (if anyone interested):


function ff(f) {
var r=Array(),i=j=k=0,fl,t;
if(f&&(f.tagName=='FORM')) {
fl=f.length;
for(i=0;i<fl;i++) {
t=false;
switch(f.elements[i].type) {
//checkbox:
case 'checkbox':
//radio:
case 'radio':
if(t=f.elements[i].checked) r[++k]=f.elements[i].name+'='+(f.elements[i].value?f.elements[i].value:1);
break;
//select:
case 'select':
case 'select-one':
r[++k]=f.elements[i].name+'='+f.elements[i][f.elements[i].selectedIndex].value;
t=true;
break;
case 'select-multiple':
for(j=0;j<f.elements[i].length;j++) {
if(f.elements[i].options[j].selectedIndex) {
r[++k]=f.elements[i].name+'='+f.elements[i].options[j].value;
t=true;
}
}
break;
default:
r[++k]=f.elements[i].name+'='+f.elements[i].value;
t=true;
}
report(encodeURI(r[k]));
if(t)r[k]=(String(encodeURI(r[k])).split('&')).join('%26');
}
//report(r);
}
return r;
}



one more thing - when will we get something similar to php tag for javascript:)?

pccode
10-13-2005, 09:21 AM
Check out these scripts:

http://www.codingforums.com/showthread.php?t=70051


Hope they help.

looka
10-15-2005, 12:35 AM
no they are not exactly im looking for - im just looking for some i dont know - perhaps a property of form which returns a string to be send... or an array..

Pyth007
10-19-2005, 12:45 AM
I'm confused as to what you are wanting...

In php, $_POST super-global array is an associative array of each named "input" element in a form...

Or in javascript, document.myFormName.getElementsByTagName('tagName') will give you a collection of elements having said tagName (eg replace 'tagName' with 'input' to get all input elements). You could do this several times to collect all elements in a form into one array...

Or you could start your own associative array onLoad and for each element's onChange, alter said array...

Maybe if you could provide a more general goal as to what you eventually want to happen, we may be able to provide more help. Also your code is somewhat difficult to understand since we don't have interpretations for 1-2 letter abbreviations for your variables (I get that f = 'form', but r, k, etc. has me stumped); this goes back to us not knowing what you want to eventually have happen...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum