Why won't my code work. I want to get data from a text file and divide it up into the different sections for outputing. The first two parts, title and owner, work fine, but the description part just prints the owner slice. Plz Help. I'm trying to make it get the data in between the ( ) Javascript Code: //parse data response = xmlhttpget.responseText; //text strend = (response.indexOf('#') + 1); responseprint = response.slice(strend,response.length); //title titlestart = ((response.indexOf('(') + 1)); titleend = (response.indexOf(')')); responsetitle = response.slice(titlestart,titleend); //owner strresponse = response.slice((titleend + 1),response.length); ownerstart = ((strresponse.indexOf('(') + 1)); ownerend = (strresponse.indexOf(')')); responseowner = strresponse.slice(ownerstart,ownerend); //description strresponse = response.slice((ownerend + 1),response.length); descriptionstart = ((strresponse.indexOf('(') + 1)); descriptionend = (strresponse.indexOf(')')); responsedescription = strresponse.slice(descriptionstart,descriptionend); //print it document.getElementById('name').innerHTML = responseowner; document.getElementById('output').innerHTML = responsedescription; Code (markup): Text File Code: Room Name(First Room) | Room Owner(Mr.World) | Room Description(Site xxx.com. 1234567890 Test Test !!! ???) | # LINE1 Code (markup): Thanks. ~imozeb
One more thing. I used AJAX to set the var 'response' = to the text from the text file. Please tell me where I went wrong or give me a suggestion of another way to do what I want.