Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>data from forms

data from forms

looka
10-12-2005, 08: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, 08:21 AM
Check out these scripts:

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


Hope they help.

looka
10-14-2005, 11:35 PM
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-18-2005, 11:45 PM
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...


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

validate using ONSUBMIT vs ONUNLOAD
Cross-Browser Menu Now Working, BUT Now Have FireFox Refresh Loop
How do you write maintainable code?
How to excecute 2 different form validation Java scrpt with 1 submit button ?
I want to Resize frames on a button click
Need Cross-Browser Capable Menu / Script - event.srcElement to getElementById
Simply splitting a date up?
Link Extractor Mod to Get Page Domains

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics