Jump to content

tinfanide

Members
  • Content Count

    445
  • Joined

  • Last visited

Community Reputation

19 Good

About tinfanide

  • Rank
    Member

Previous Fields

  • Languages
    (X)HTML, CSS, JS/JSON, AS, AJAX, XML, PHP, SQL

Contact Methods

  • MSN
    tinfanide@hotmail.com
  • Website URL
    http://lifelearning.x10.mx/

Profile Information

  • Location
    China
  • Interests
    C#, ActionScript
    Just wanna script something that is useful for my daily life...
  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()?>
×
×
  • Create New...