Jump to content

tinfanide

Members
  • Content Count

    445
  • Joined

  • Last visited

Everything posted by tinfanide

  1. xmlDoc = xml.responseXML; table = document.createElement("table"); Employees = xmlDoc.getElementsByTagName("Employee"); for (x=0; x<Employees.length+1; x++) { if (x==0) { tr = table.insertRow(-1); // does not work tr.className = "header"; tr.setAttribute("class","header"); for (z=0; z<5; z++) { th = tr.insertCell(z); th.innerHTML = headers[z]; } } else { tr = table.insertRow(-1); Employee = Employees[x-1].getElementsByTagName("*"); for (y=0; y<Employee.length; y++) { td = tr.insertCell(y); td.innerHTML = Employee[y].textContent; } } if ((x-0)%2 == 0) { if (tr.className != "header") {tr.className = "even";} } } document.body.appendChild(table); The red-highlighted codes don't work but the HTML codes work. It seems my external CSS sheet does not work with the javascript, but HTML. The whole site is here for reference (just for testing): http://lifelearning.xtreemhost.com/_json_xml_parsing/get_json_xml.html?i=1 <table> <tr class="header"><th>Header ONE</th><th>Header TWO</th></tr> <tr><td>Cell 1</td><td>Cell 2</td></tr> <tr class="even"><td>Cell 1</td><td>Cell 2</td></tr> <tr><td>Cell 1</td><td>Cell 2</td></tr> <tr class="even"><td>Cell 1</td><td>Cell 2</td></tr> </table> Here's the CSS codes: table, th, td { width: 800px; border: 1px solid black; } table td { font-size: 16px; } tr.header { font-size: 36px; } tr.even { background-color: #dddddd; }
  2. @davej <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>title</title> </head> <style> th { font-size: 30px; /* doesn't work */ } td { font-size: 20px; /* works for both <th> and <td> */ } </style> <script type="text/javascript"> var xmlhttp; var Staff, obj; var url = "staff.json"; function init() { xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ; xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { Staff = JSON.parse(this.responseText); var table = document.createElement("table"); document.body.appendChild(table); obj = Staff.Staff[0]; for (var y in obj) { var header_row = document.createElement("th"); var column = document.createElement("td"); var data = document.createTextNode(y); column.appendChild(data); header_row.appendChild(column); table.appendChild(header_row); } for(var x=0; x<Staff.Staff.length; x++) { obj = Staff.Staff[x]; var row = document.createElement("tr"); if (x%2 == 0) row.setAttribute("class","even"); for (var y in obj) { var column = document.createElement("td"); var data = document.createTextNode(obj[y]); column.appendChild(data); row.appendChild(column); table.appendChild(row); } } } }; xmlhttp.open("GET",url,true); xmlhttp.send(); } window.onload = init; </script> <body> </body> </html> The table is generated through JavaScript and JSON.
  3. th { font-size: 30px; /* doesn't work */ } td { font-size: 20px; /* works for both <th> and <td> */ } I'd like to ask why the font-size of <th> and <td> must be the same. Thanks for any help.
  4. var xmlhttp; var Staff, obj; var url = "staff.json"; function init() { xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ; xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { Staff = JSON.parse(this.responseText); var table = document.createElement("table"); document.body.appendChild(table); obj = Staff.Staff[0]; for (var y in obj) { var header_row = document.createElement("th"); var column = document.createElement("td"); var data = document.createTextNode(y); column.appendChild(data); header_row.appendChild(column); table.appendChild(header_row); } for(var x=0; x<Staff.Staff.length; x++) { obj = Staff.Staff[x]; if (x%2 == 0) { var row = document.createElement("tr"); row.setAttribute("class","even"); // function? for (var y in obj) { var column = document.createElement("td"); var data = document.createTextNode(obj[y]); column.appendChild(data); row.appendChild(column); table.appendChild(row); } } else { var row = document.createElement("tr"); // function? for (var y in obj) { var column = document.createElement("td"); var data = document.createTextNode(obj[y]); column.appendChild(data); row.appendChild(column); table.appendChild(row); } } } } }; xmlhttp.open("GET",url,true); xmlhttp.send(); } window.onload = init; Since the codes below "// function?" are repeated (either the row to be created in the JavaScript is odd or even), how can I write the same codes into ONE function to be shared and used in different places? Thanks for any help!
  5. I'm not sure if I'm posting this ques in a correct forum (whether it's related to HTML). I'd like to ask: When I type the addr below (just an example), http://ss.activate.ilongman.com/getfile/269/id/415 it'll redirect me to download a file. How is it made? Is it PHP? Or just HTML / JS redirecting? Another ques is: I'd like to batch download (automate downloading) the files according to the pattern (xxx): http://ss.activate.ilongman.com/getfile/xxx/id/415 What program language should I use to achieve this? Thank you.
  6. The file I want to modify is an mp4 video file (of course a bunch of them; that's why I need to do it programmatically). But I wonder why an API is needed. Does VBScript not support it natively? It can read those properties by FolderItem.GetDetailsOf(), yet can't write it, can it?
  7. I have successfully modified the file properties of MS Office files with the use of DSOFile. But how can files other than those be modified?
  8. <style type="text/css">table{ border-collapse: collapse;}table th{ text-align: left; }td { border-bottom: 1px solid #F00;}table th, table td{ padding: 5px 10px; }</style> Yes, change from <tr> to <td>. That's one thing. Another thing is that "table border-collapse: collapse" does inhibit border-bottom in TABLE. (in FF)
  9. // ...session_unset(); // added this linesession_destroy();// ... Yes. Checked online and added the session_unset() function.
  10. I wonder why session_destroy() does not work on the page (destroy_session.php). Set the session: http://learntolive.x10.mx/PHP/Sessions/set_sessions.php <?phpsession_start();$_SESSION['username'] = "username1";$_SESSION['password'] = "password1";$_SESSION['array'] = array('array0','array1','array2');?><html><head><script type="text/javascript">var sPageFullPath = String(window.location.href);var iDelim = sPageFullPath.lastIndexOf("/");var sPageRootPath = sPageFullPath.substring(0,iDelim+1);var iCount = 3;var iTimerCount = iCount*1000;var sRedirectURL = "get_sessions.php";window.onload = CountdownTimer;function CountdownTimer(){ if (iCount>0) { document.getElementById("CountdownTimer").innerHTML = "This page will redirect in "+iCount+" seconds to " + sRedirectURL; iCount--; setTimeout("CountdownTimer()",iTimerCount); } else { window.location = sPageRootPath + sRedirectURL; }}</script></head><body><p>This page assigns values to SESSION valuables.</p><p id="CountdownTimer"></p></body></html> Get the session: http://learntolive.x10.mx/PHP/Sessions/get_sessions.php <?phpsession_start();echo "This page shows values to SESSION valuables."."<br />";echo "The username is ".$_SESSION['username'];echo "<br />";echo "The password is ".$_SESSION['password'];echo "<br />";echo "The array is ".$_SESSION['array'][2];echo "<br />";foreach ($_SESSION['array'] as $value){ echo $value; echo "<br />";}echo "<hr />";print_r ($_SESSION);echo "<hr />";?><html><head></head><body><a href="destroy_sessions.php" title="This page will destroy the session valuables.">destory sessions</a></body></html> Destroy the session: http://learntolive.x10.mx/PHP/Sessions/destroy_sessions.php <?phpsession_start();echo "This page desttoys the session.";echo "<br />";session_destroy();echo "Those sessions set will not be shown now.";echo "<br />";echo "The username is ".$_SESSION['username'];echo "<br />";echo "The password is ".$_SESSION['password'];echo "<br />";echo "The array is ".$_SESSION['array'][2];echo "<br />";foreach ($_SESSION['array'] as $value){ echo $value; echo "<br />";}echo "<hr />";print_r ($_SESSION);?> On the above PHP page, the session valuables are still shown properly.
  11. First, I wonder why "border-bottom: 1px solid #ccc" should go with "border-collapse: collapse" in order to come into effect. Second, it is not compatible across all browsers to the best I know (only IE8+, Chrome support). In FF or IE7-, the bordor-bottom does not come out. The test page: http://learntolive.x10.mx/HTML/table.html
  12. Sorry to both who've answered me.I should have shown you the whole codes instead of the one that is wrong and that was just typed by me in the example. Sub a()Dim oIE As SHDocVw.InternetExplorerSet oIE = New SHDocVw.InternetExplorerDim oHTML As HTMLDocumentoIE.Visible = TrueoIE.navigate "http://www.website.com/"While oIE.Busy DoEventsWendSet oHTML = oIE.documentDim oTr As HTMLTableRowFor Each oTr In oHTML.getElementsByTagName("tr")''' return Null Debug.Print oTr.getAttribute("Style.backgroundImage")Next oTr End Sub I think I should have posted it in the VBA forum. Well, but sorry I have started it here.
  13. <tr style="background-image: url("background-image.jpg")"></tr> I wonder how we can get the attribute (url).I'm not sure about it. document.getElementsByTagName("tr").getAttribute("style.backgroundImage");
  14. Yes, ya're right. And you've made a point.First, the pre tag is not accepted by PHP. After removing the tags, the warning generated by PHP disappears.Second, the DOMDocument method achieves what I want. I don't need an external lib like the Simple HTML Dom. By the way, I can't check up online. I wonder if I can do this in PHP:<?phpecho $html->getElementsByTagName('li',0)->childNodes[0]->textContent;// it generates warnings// instead of using item()?>
  15. <body><ul id="ul1"><li id="pt1">Point 1 <ul id="ul2"> <li id="pt11">Point 1.1</li> <li id="pt12">Point 1.2</li> <pre class="CodeDisplay"> some codes </pre> <li id="ref">Reference: <a href="link.html" target="_blank">link</a></li> </ul> </li></ul></body><script> alert(document.getElementsByTagName("li")[0].childNodes[0].nodeValue); // Point 1 </script> In JS, it returns what I want.Is there an equivalent in the simple HTML Dom of PHP?
  16. It returns a large chunk of unreadable texts which I can't understand.
  17. <?php// Simple HTML DOM Parserinclude('simple_html_dom.php');$html = file_get_html('http://lifelearning.xtreemhost.com/'); foreach ($html->getElementsByTagName("ul",0)->getElementsByTagName("li") as $li){echo $li->plaintext; // works; but return the whole nodeValues (From "Point 1" to "Reference") echo $li->childNodes(0)->nodeValue; // return nothingecho "<br />";}?> <ul><li>Point 1 <ul> <li>Point 1.1</li> <li>Point 1.2</li> <pre class="CodeDisplay"> some codes </pre> <li>Reference: <a href="link.html" target="_blank">link</a></li> </ul> </li> </ul> I want to just thru PHP get the plain text of the first li ("Point 1").How can I do that in PHP?
  18. I want to ask if there is any free MySQL server that supports remote access.People say FreeMySQL.net is one of the choices but I cannot connect to it through a PHP script on another web hosting server.Any idea?
  19. Dim oConn As ADODB.ConnectionPrivate Sub ConnectDB()Set oConn = New ADODB.ConnectionDim str As Stringstr = "DRIVER={MySQL ODBC 5.2.2 Driver};" & _ "SERVER={???};" & _ "PORT=3306" & _ "DATABASE=xth_9595110_MyNotes;" & _ "UID=xth_9595110;" & _ "PWD=myPassword;" & _ "Option=3"oConn.Open strEnd Sub Private Sub InsertData()Dim rs As ADODB.RecordsetSet rs = New ADODB.RecordsetConnectDBsql = "SELECT * FROM ComputingNotesTable"rs.Open sql, oConn, adOpenDynamic, adLockOptimisticDo Until rs.EOF Range("A1").Select ActiveCell = rs.Fields("Headings") rs.MoveNextLooprs.CloseoConn.CloseSet oConn = NothingSet rs = NothingEnd Sub I would like to ask what I should fill in in the server name if I am connecting to Xtreemhost MySQL databases. It returns run-time errors.
  20. And now I'm thinking of making use of the Simple HTML Dom parser. Basically I want to copy the Dom structure of the page:http://lifelearning.xtreemhost.com/simple.html and show part of the structure in this page:http://lifelearning.xtreemhost.com/board.php <?phprequire_once 'simple_html_dom.php';$html = new simple_html_dom();$html->load_file('http://lifelearning.xtreemhost.com/simple.html');echo $html->find('div[id]');?> But the board PHP page shows the error: And I followed the tutorial on http://www.youtube.com/watch?v=zTJk0_2p8tc&list=PLE1036D2604E505E7&index=17&feature=plpp_video
  21. Sorry, I don't quite understand what ya guys're discussing. But I go search a bit and find two solutions to achieve what I want: file_get_contentsBut this only copies the HTML contents. I cannot break it down and take the unordered list contents away. simple HTML dom parserIt seems I can make use of the DOM structure to take away what I want but I do not know what to do (after receiving an error), including the php page on my server. Could anyone tell me how to use the simple HTML dom parser?It returns errors when I just include the page in my PHP script after putting the PHP page (simple_HTML_dom_parser page) on the server. Many thanks.
  22. If a webpage has the following structure, <ul><li>point 1</li><li>point 2</li><li>point 3</li></ul> how can I copy the content (in the form of texts) to a SQL database PROGRAMMATICALLY?For example, transfer "point 1" to the first row of a SQL table and "point 2" and "point 3" accordingly.Does it involve work of writing a program to analyse the content of the webpage before uploading the content into the database using server-side languages?
×
×
  • Create New...