if i have the following line of code, could i somehow get the value of each textfield by assigning it to an array??? function submitSave() { var iarray = new Array(); for (i=0; i<numItems; i++) { document.getElementById("textfields").value = iarray; } } Code (markup):
What this will do is it will convert the content of the array to a comma-delimited list of values (which will be empty in this case 'cause you just created an array) and assign it to the text field. Simply put, this assignment will reset the content of "textfields" to a zero-length string. J.D.
var iarray = "value1_value2_value3".split('_'); for (i=0; i<iarray.length; i++) { document.getElementById("textfields").value = iarray; }
If you want to get the values from the FORM into the ARRAY, then you need something like: for (i=0; i<numItems; i++) { iarray=document.getElementById("textfields" + i).value; } Something like this, anyway..
You have a div you want to write to. Make it : <div id="holder"></div>.Then - document.getElementById("holder").innerHTML = blah You cannot get info from submit into javascript. You must post, or alternately, get, with the submit call from your input text form (on submit="file.php" action="post/get"). Lets say you make a httprequest for "doc.xml", either in the 'onload' function, or with an evewnt caller: function sendRequest(doc){ // check for existing requests if(xmlobj!=null&&xmlobj.readyState!=0&&xmlobj.readyState!=4){ xmlobj.abort(); } try{ // instantiate object for Mozilla, Nestcape, etc. xmlobj=new XMLHttpRequest(); } catch(e){ try{ // instantiate object for Internet Explorer xmlobj=new ActiveXObject('Microsoft.XMLHTTP'); } catch(e){ // Ajax is not supported by the browser xmlobj=null; return false; } } // assign state handler xmlobj.onreadystatechange=stateChecker; // open socket connection xmlobj.open('GET',doc.xml,true); // send GET request xmlobj.send(null); } Then, you check for a return: function stateChecker(){ // if request is completed if(xmlobj.readyState==4){ // if status == 200 display text file if(xmlobj.status==200){ // create data container createDataContainer(); // read XML data data=xmlobj.responseXML.getElementsByTagName('message'); // display XML data displayData(); } else{ alert('Failed to get response :'+ xmlobj.statusText); } } } in which you have : <div id="container"></div>, and you : document.write.getElementById.innerHtml. eg: function createDataContainer(){ var div=document.getElementById('container'); if(div){return}; var div=document.createElement('div'); div.setAttribute('id','container'); document.getElementsByTagName('body')[0].appendChild(div); } If you: var item = new item item = getElementById.innerHtml() {... Okay, I am way past bedtime. Here is better explanation: yeah, I wish I new this, LMAO: Oh boy: You don't have to create text links, this ias just an example I copied from DevShed: JavaScript Remote Scripting: Processing XML Files You can assign anything as a var, then use it however, of course. From above: You can read this guy, he is the best one of many I have read, more advanced, but very clear: Alejandro Gervasio THIS: JavaScript Remote Scripting: Fetching Server Data with the DOM Basically, what I have been doing, is getting individual sets and assigning them by each as they come: document.getElementById("id_name").innerHTML(){ if(is==good){ blah; } else(is_not_good){ other blah; }} document.write=nextRoundIsOnMe.getWalletByLocation ;o)))
Here, I grab a ton of stuff, all from one xml file, and assign it to three different places(marker points, sidebar, hidden div[info window]): [i] [url]http://mikx2.com/mikmap/wowza.php[/url] From an xml file: [QUOTE] <?xml version="1.0" ?> - <markers> <marker lat="27.99381657128786" lng="86.82481689453125" location="Webfuscious" img="../pics/250px-Mt_Everest_aerial_2005.jpg" link1="Top of the World" url1="http://www.everestnews.com/" address="6000 Ft. Base, Mt Everest" groupid="Asia,Australia" /> <marker lat="27.99381657128786" lng="86.82481689453125" location="Webfuscious" img="../pics/250px-Mt_Everest_aerial_2005.jpg" link1="Top of the World" url1="http://www.everestnews.com/" address="6000 Ft. Base, Mt Everest" groupid="Asia,Australia" /> <marker lat="49.8862016713458" lng="-119.48206901550293" location="mikmik" link1="Mikx2" url1="http://mikx2.com/" link2="Factor1" url2="http://factor1.net/" address="Kelowna" groupid="Canada,Australia" /> <marker lat="47.5189252" lng="-100.88691473" location="rocky" img="../pics/rocky1.jpg" img_height="75" link1="North Dakota Fishing" url1="http://www.rtfi.us/" address="Turtle Lake" groupid="UnitedStates" /> <marker lat="44.9327" lng="-75.613" location="minstrel" link1="PsychLinks Online" url1="http://forum.psychlinks.ca/" link2="Written Voice" url2="http://www.writtenvoice.com/" address="Oxford Mills" groupid="Canada" /> <marker lat="28.5435" lng="-81.3963" location="Steven" link1="Ogre Hosting" url1="http://www.ogrehosting.com/" link2="Cold Fusion Programming" url2="http://www.veradicetechnologies.com/" address="Orlando, Florida" groupid="UnitedStates" /> <marker lat="26.7189" lng="-80.1248" location="Daren" link1="Web Page Turner" url1="http://www.webpageturner.com/" address="West Palm Beach, Florida" groupid="UnitedStates" /> <marker lat="51.590723" lng="-0.131836" location="Centaur" img="../pics/erimusLogo.gif" img_height="77" link1="Erimus Web Desaign" url1="http://www.erimus.com/" link2="SVG Software Solutions" url2="http://www.inbay.co.uk/" address="London, England" groupid="Europe" /> </markers> [/QUOTE][/i]
Thanks guys for all your help. I've got this code so far, however, it seems like nothing is getting returned in the array. The alert keeps returning undefined...can someone please help me. function submitSave() { var iarray = new Array(); for (i=0; i<numItems; i++) { iarray[i] = document.getElementById("textfields").value; alert(iarray[i]); } } Code (markup):
Hi, The code you are using assumes that all the fields you want to read are called textfields0 textfields1 textfields2 textfields3 etc. If your fields are called txtFirstName, txtLastName, txtAddress etc - then this will not work. Also, the code assumes you have a global variable called numItems, and that it is set to something higher than 0. Hope this helps. How about posting a more complete example?