Jump to content

Java script help


Alec
 Share

Recommended Posts

Hi all,I have the ollowing HTML file and I am trying to move the table and make it a static table inside <div id= dvtable>it is not pulling the information from the xml file if i move it.anybody can help?<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="jquery.ba-dotimeout.js"></script> <script type="text/javascript"> $(document).ready(function(){ //gets the xml configuration file and creates an multidimension array called schedule and hands it off for display jQuery.get("schedule.xml", {}, function(xml) { var schedule = [] //iterates through the xml file and creates the schedule multidimension array $(xml).find('item').each(function(i){ var id = $(this).attr('id'); schedule[id] = { title: $(this).find('title').text(), position: $(this).find('position').text(), duration: $(this).find('duration').text(), url: $(this).find('url').text() } }); //end of each //passes the schedule multidimension array for display displayResults(schedule); }); //end of get }); //end of document.ready function displayResults(schedule){ var counter = 0; var z = 0; $.each(schedule, function(intIndex, objValue){ z = z + parseInt(objValue.duration); }); //this will give us a very long initial delay. How often should be iterate through? $.doTimeout(z, function(){ //be careful as this will override the exception $.each(schedule,function(intIndex, objValue){ setTimeout(function() { $('#iframe1').attr('src', objValue.url); }, this.duration * intIndex); }); //end of each //if ( counter < 50 ) { return true; } // Poll. not sure about this counter return true; //this will make it loop }); } </script> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup ({ cache: false }); $.doTimeout(30000, function(){ $.ajax({ type: "GET", //url: "http://neptune.atlantixglobal.com:1048/cgi-bin/db2www/qsys.lib/sdsrc.lib/macros.file/tvsalesexc.mbr/report", //url: "result2.xml", url: "http://reports.atlantixglobal.com/tvs/files/result2.xml", cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ $('#table1').append('<tr ><td width="80%" align="center"><span style="font-size:80px"><FONT COLOR=RED FACE="sans-serif" ><B>Congratulations ' +$(this).find('name').text() +' !!!</B></FONT></span></td></tr>'); $('#table1').append('<tr ><td><FONT COLOR=white>......</FONT></td></tr>'); $('#table1').append('<tr ><td align="center"><span style="font-size:75px"><FONT FACE="Tahoma" ><B><i> You just closed a </i></B></FONT></span></td></tr>'); $('#table1').append('<tr ><td><FONT COLOR=white>......</FONT></td></tr>'); $('#table1').append('<tr ><td align="center"><span style="font-size:90px"><FONT COLOR= BLUE FACE="Tahoma" ><B><i> $ ' + $(this).find('amount').text() +' deal</i></B></FONT></span></td></tr>'); $('#table1').append('<tr ><td><FONT COLOR=white>......</FONT></td></tr>'); $('#table1').append('<tr ><td align="center"><span style="font-size:80px"><FONT FACE="Tahoma" ><B><i> with ' +$(this).find('customer').text() +'</i></B></FONT></span></td></tr>'); $('#iframe1').hide(); }); } }); $.doTimeout(10000, function(){ $("#table1 tr").remove(); $('#iframe1').show(); }); return true; }); }); </script> <style type="text/css"> .myTableStyle { position:absolute; top:10%; left:5%; } </style> </head><body> <table id = "table1" class="myTableStyle" ></table> <div id="1" style="z-index:10"> <iframe id="iframe1" src="" width="1920px" height="1080px" frameborder="0" scrolling="auto" style="border:0px solid #000000"> </iframe> </div> <div id="2" style="z-index:1"> <iframe id="iframe2" src="" width="100%" height="1000" frameborder="0" scrolling="auto" style="border:10px solid fff000"> </iframe> </div> </body> </html>

Link to comment
Share on other sites

I am trying to get rid of the table so I can simplify the code.in order to do I was trying to move the information from inside the table into a div inside the html body.I'v been working on this for awhile :)(Hope I can get some help

Link to comment
Share on other sites

so what I am thinking to do is to move the data from the table and add it in a div in the html body .and then I call the div and remove it instead of having the table in the JS scriptI've been trying to do but not working!!

Link to comment
Share on other sites

This thread has gotten very confusing. Please explain if this describes the situation:An XML file exists on your server or someone else's server.A user loads an HTML file from your server into their browser.The HTML document uses AJAX to get the XML document.Then the HTML document writes the XML data into itself.Yes? No?

Link to comment
Share on other sites

This thread has gotten very confusing. Please explain if this describes the situation:An XML file exists on your server or someone else's server.A user loads an HTML file from your server into their browser.The HTML document uses AJAX to get the XML document.Then the HTML document writes the XML data into itself.Yes? No?
Yes indeed..:)
Link to comment
Share on other sites

Okay. You need to test things.First you need to see if your AJAX request actually returned anything.Then you need to see if what it returned has been successfully turned into an XML object.With jQuery, maybe those two steps can be combined.Then you need to see if your XML functions are correctly access your XML data. Don't confuse the process by gooping it up with a lot of table stuff. You can do that later if you need to. Just see if you can write your XML strings into a div, may separating them with <br> elements, but nothing more complicated.What is going on with all the delays you're building into this thing? Why do you think that is necessary?

Link to comment
Share on other sites

Okay. You need to test things.First you need to see if your AJAX request actually returned anything.Then you need to see if what it returned has been successfully turned into an XML object.With jQuery, maybe those two steps can be combined.Then you need to see if your XML functions are correctly access your XML data. Don't confuse the process by gooping it up with a lot of table stuff. You can do that later if you need to. Just see if you can write your XML strings into a div, may separating them with <br> elements, but nothing more complicated.What is going on with all the delays you're building into this thing? Why do you think that is necessary?
the query as it is fine..everything in is working perfect and I am getting what I need from the XML file using Jquery.what I need to do is to move the output into div tags and then call the div instead of having the whole table.I tried several ways but it is not working..
Link to comment
Share on other sites

I tired to delete the table and added <div id ="divtable" class = "divRelative" > <script type="text/javascript"> $.doTimeout(30000, function(){ $.ajax({ type: "GET", //url: "http://neptune.atlantixglobal.com:1048/cgi-bin/db2www/qsys.lib/sdsrc.lib/macros.file/tvsalesexc.mbr/report", url: "result2.xml", cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ document.write ("<font color=red>"+$(this).find('name').text()+"<br></font>"); document.write ("<br>"); document.write (parseInt($(this).find('amount').text())); document.write ("<br>"); document.write ($(this).find('customer').text()); $('#iframe1').hide(); }); } }); }); </script> </div> inside the html body..I got the data working but lost the overwritting to show the other slides

Link to comment
Share on other sites

Don't use document.write. Build the complete HTML string first, then use innerHTML to update the div.
I am sorry but i am not that expert...could you tell me how to do that or is there any examples i can take a look at?Thanks,
Link to comment
Share on other sites

Thxs, I tried it ..it is working ..the only problem is that when the process goes back to repeat cycle it stock on one of the slides and I am getting :document.getElementById('name').innerHTML= $(this).find('name').text(); is nullany ideas ?!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...