Jump to content

hacknsack

Members
  • Posts

    183
  • Joined

  • Last visited

Everything posted by hacknsack

  1. How about using opendir() to open the directory.Read the contents (file names) with readdir() and store them in an array,sort the array (by file name) and then use the array to build your output.
  2. If you do a view source on the non-working version you'll notice that your action is blank ( for the form ). <?php echo $PHP_SELF ?> The code above must be returning a blank string, on the non-working server.Try: <?php echo $_SERVER['PHP_SELF'] ?> Also, I would check the submit with something like: if(isset($_POST['submit'])) Hope this helps you.
  3. Glad to help out. :)Thanks for the feedback.
  4. You're welcome. See if this will get you going, using insertBefore(): <html> <head> <title></title> <script type="text/javascript"> function editLinks(){ var re = /showuser=(\d+)/; var links = document.getElementsByTagName('a'); var img_src = "http://www.google.com/images/firefox/light.gif"; for(var j = 0; j < links.length; j++){ if(links[j].href.match(re)){ if(navigator.userAgent.indexOf('MSIE') > -1 && navigator.userAgent.indexOf('Opera') == -1){ var nwImg = document.createElement('<img src="' + img_src +'" onclick="alert(' + RegExp.$1 +')">'); } else { var nwImg = document.createElement('img'); nwImg.setAttribute('src', img_src); nwImg.setAttribute('onclick', "alert('" + RegExp.$1 + "')"); } oParent = links[j].parentNode; oParent.insertBefore(nwImg, links[j]); } } } window.onload = editLinks; </script> </head> <body> <table> <tr> <td> <a href="http://s15.invisionfree.com/Redified/index.php?showuser=2">User 2</a> <a href="http://s15.invisionfree.com/Redified/index.php?showuser=24">User 24</a> </td> <td> <a href="http://s15.invisionfree.com/Redified/index.php?showuser=13579">User 13579</a> </td> </tr> </table> </body></html> Shout back if it needs adjustments.
  5. Sounds like you are on the right track:<html> <head> <title></title> <script type="text/javascript"> var g = 'default'; function registerThis(str){ g = str; } function testVar(){ alert(g); } </script> </head> <body> <a href="http://www.google.com" title="Google Link" onmouseover="registerThis(this.title)">Google</a> <form> <input type="button" value="Check Registered" onclick="testVar()"> </form> </body></html> Hope it helps.
  6. How about splitting the string? <script type="text/javascript"> function parseStr(str){ var temp = str.split("="); alert(temp[1]); } parseStr('http://www.somesite.com/index.php?showuser=1'); </script> Would that work out for you?
  7. hacknsack

    Include Annoyances

    Are you sure you have set your file path correctly.include()Informit Article
  8. hacknsack

    Go first mysql

    You can use mysql_data_seek() to set the pointer back to the first row.An article that might help:Melonfire ArticleIt is good to recycle
  9. Since you are using mysql_fetch_object that is how you have to access the "properties".Consider an object a "special array" that uses properties as it's index.So the -> takes the place of []http://www.tonymarston.net/php-mysql/databaseobjects.htmlMaybe that article will help.
  10. This works in FF, IE and Opera ( I can't say about Safari ).There is a title attribute that you can utilize.Recommend that you use a span instead, included it here: <html> <head> <title></title> <style type="text/css"> .blue { color: #0080FF; } .red { color: #FF8040; } </style> <script type="text/javascript"> function e1v16(winner) {document.forms[0].east1v16.value=winner} function e8v9(winner) {document.forms[0].east8v9.value=winner} </script> </head> <body><font color="0080FF" onclick="e1v16(this.title)" title="Illinois">Illinois</font><font color="FF8040" onclick="e1v16(this.title)" title="Fair Dickinson">Fair Dickinson</font><font color="0080FF" onclick="e8v9(this.title)" title="Texas">Texas</font><font color="FF8040" onclick="e8v9(this.title)" title="Nevada">Neveda</font><form name="testForm"><input type="text" name="east1v16" size="7%" onclick="e16_1(document.forms[0].east1v16.value)"></input><input type="text" name="east8v9" size="7%" onclick="e16_1(document.forms[0].east8v9.value)"></input></form><span class="blue" onclick="e1v16(this.title)" title="Illinois">Illinois</span><span class="red" onclick="e1v16(this.title)" title="Fair Dickinson">Fair Dickinson</span><span class="blue" onclick="e8v9(this.title)" title="Texas">Texas</span><span class="red" onclick="e8v9(this.title)" title="Nevada">Neveda</span> </body></html> Thanks,
  11. The posted fields are an array, you declare them in the(html) form as name="info[]".You also have to adjust the way you reference these in your javascript validation. <html><head><script type="text/javascript">function Validate4( ){var Lform = document.forms['form4'];var info = Lform.elements['info[]'];var boxes = info.length;var txt = "";for (i = 0; i < boxes; i++){ if(info[i].checked) { txt = txt + info[i].value + " "; }}if(txt == ''){alert("No textbox ticked");return false;}return true;}</script></head><body><?phpif(isset($_POST['info'])){ $boxArray = $_POST['info']; echo "You checked the following:<br>"; foreach($boxArray as $x => $val){ echo "$val<br>"; }}?><form name="form4" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onSubmit="return Validate4()">Info Needed :<br><input type=checkbox name="info[]" value="HC11">HC11<br><input type=checkbox name="info[]" value="HC12">HC12<br><input type=checkbox name="info[]" value="8051">8051<br><input type=checkbox name="info[]" value="8086">80X86<br><input type=checkbox name="info[]" value="PIC">PIC<br><input type=checkbox name="info[]" value="DSP">DSP<input type="submit"></form></body></html> Thanks,
  12. Two good articles here:Parsing XMLTutorial with ExampleAfter you know what makes it tick you can build your own.Both of the above include sample code.If you have questions let us know.
  13. Don't see anything out of place.Maybe you have an escaped quote or something before the function.No warnings or errors with your function: <?php function whatis($name){ $checktype = explode('|', $name); $checkfile = explode('.', $name); if(count($checktype) >=2 && $checktype[1] == 'Category') return 'Category'; elseif(count($checktype) >=2 && $checktype[1] == 'Subcategory') return 'Subcategory'; elseif(count($checkfile) <= 3) return 'File'; else return 'Undesirable'; } $str = "One|Category|Three";echo "<p>". whatis($str) ."</p>";$str = "One|Subcategory|Three";echo "<p>". whatis($str) ."</p>";$str = "One.Two.Three";echo "<p>". whatis($str) ."</p>";$str = "One.Two.Three.Four.Five";echo whatis($str);?> You will have to keep looking for the culprit.I guess you have already tried commenting blocks of your code.
  14. You fellows are funny..And I thought the "O" was for Opera Maybe this will help with the problem, <html> <head> <title></title> <script type="text/javascript"> function mkDiv(){ var cssStyle = "position: absolute; top: 150px; left: 50px;"; if(window.ActiveXObject){ var nDiv = document.createElement('<div style="' + cssStyle + '">'); } else { var nDiv = document.createElement('DIV'); nDiv.setAttribute('style', cssStyle); } var nText = document.createTextNode('This is our new div'); nDiv.appendChild(nText); document.getElementById('holder').appendChild(nDiv); } window.onload = mkDiv; </script> </head> <body> <div id="holder"> </div> </body></html> Please join: FFSCIE(Folks For Standards Compliant IE)
  15. Adapting the code from this example:HTTP RequestWe can set a timeout and call a php page, this page happens to read the url value.But you could open a file and read a line.status.php <?phpheader('Content-type: text/xml');$counter = 0;if(isset($_GET['cycle']))$counter = intval($_GET['cycle']);function txMsg(){global $counter; if($counter < 10) {echo '<?xml version="1.0" encoding="ISO-8859-1"?><span id="status">We have requested an update '. $counter .' times.</span>'; }else {echo '<?xml version="1.0" encoding="ISO-8859-1"?><span id="status">Whatever it was, it\'s done...</span>'; }}txMsg();?> getStatus.html <html><head><style type="text/css">span {color: #66ff66;background-color: #000000;font: bold 1em arial;}</style><script type="text/javascript">var xmlhttp;var cycle = 0;function getStatus(){var url = 'status.php?cycle=' + (cycle++);// code for Mozilla, etc.if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=state_Change; xmlhttp.open("GET",url,true); xmlhttp.send(null); }// code for IEelse if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); if (xmlhttp) { xmlhttp.onreadystatechange=state_Change; xmlhttp.open("GET",url,true); xmlhttp.send(); } }}function state_Change(){// if xmlhttp shows "loaded"if (xmlhttp.readyState==4) { // if "OK" if (xmlhttp.status==200) { document.getElementById('A1').innerHTML=xmlhttp.responseText; if(cycle <= 10) setTimeout('getStatus()', 1000); } else { alert("Problem retrieving XML data:" + xmlhttp.statusText) } }}setTimeout('getStatus()', 1000);</script></head><body><h2>Using the HttpRequest Object</h2><p><b>status:</b><span id="A1">Initializing</span></p></body></html> Hopefully this will give you an idea,
  16. You're welcome, glad it was helpful.
  17. Hi and welcome to the forum,Your page indicates that you have a pretty good idea of how to implement php's mail function. You are missing an opening form tag and a field (Melding) needs to match your variable name, you have a missing '}', and don't forget that the mail function's arguments are TO, SUBJECT, MESSAGE, HEADERS.php mail()I'll send you a PM with a working copy.Thanks,
  18. There are a couple of ways to do this, but I suspect they are using a xmlhttp request.Like the one here, you could arrange a request that checks a status condition:XMLHTTP RequestThe Mozilla site has an article and examples here:Ajax:Getting StartedYou should be able to do a view source on the page you are referring to and get an idea.
  19. You could put your select options in an array and then build your select.This is how you want to make an option "pre-selected". <option selected value="someValue">TEXT</option> Option Tag( selected ) <?php$selArray = array('City Square','Headrow','University');$startstation = '';if(isset($_POST["startstation"]))$startstation = $_POST["startstation"];foreach($_POST as $key=>$val){ echo "$val is $key.<br />\n";}echo '<form name="f1" method="post" action="'. $_SERVER['PHP_SELF'] .'"> <select name="startstation">'; foreach($selArray as $i=>$value){ if($startstation == $value){ echo '<option selected value="'. $value .'">'. $value . "</option>\n"; continue; } echo '<option value="'. $value .'">'. $value . "</option>\n"; } echo '</select> <input type="submit"> </form>';?> Thanks,
  20. Happy to see that you've had success!That is the cool thing about php, ( I think ) , it's very easy to get used to.I do have a comment, looks like you are opening the file twice, the work is done here: $array = file('dates.txt'); Unless there is something you have not included these lines create duplicate processes: $fil = fopen('dates.txt', r);$dat = fread($fil, filesize('dates.txt'));fclose($fil); Also, an operator that you will get to like is the "++" it increments a variable for you.php operatorsSomething else that you could investigate is the loop:php loopsWhen you are doing the same thing again and again, good to use a loop.Good Job,
  21. hacknsack

    IE woes

    Commenting the following line recovered somewhat.I also would like to cast a vote against IE, nice to notice in the browser-stats that it's losing it's popularity somewhat. #menu{ width: 150px; float: left; color: #333333; /* position: relative; */ } Good Luck,
  22. Surely, glad to help out. I think I understand the first part of your project but you are losing me here: This will get the file line:<?php// adjust for starting line index of 0$captureLine = date("j") - 1;$lines = file('data.txt');foreach ($lines as $line_num => $line) { if($line_num == $captureLine){ echo "File line ". ($line_num + 1) ." is: $line <br />\n"; break; }}?> TGIF . .
  23. One resource that will be handy for you is php's mktime function which returns a timestamp that you can use along with php's date function to calculate future and past dates.date()mktime() <?phpecho "Today is: ". date("F j, Y") . "<br />";// put today's values into our variableslist($sMonth, $sDay, $sYear) = explode(",", date("n,j,Y"));echo "$sMonth is the Month, $sDay is the Day, $sYear is the Year";echo "<br />";// add 27 days and get the new date$futureDate = date("F j, Y", mktime(0, 0, 0, $sMonth, $sDay + 27, $sYear));echo "Future Date is: $futureDate"; ?> Hopefully this will give a starting point.
  24. You will have to figure out how you want to test browsers.Opera (version 8.5) now passes the document.all test so I threw in a userAgent test here:Anyway here is a reference regarding IE's method to "createElement":createElementand attachEvent:attachEvent <HTML><head><script type="text/javascript">function addRow(){if(window.attachEvent && navigator.userAgent.indexOf('Opera') == -1){var selectBox = document.createElement('<select name="selectBox" id="selectBox" onChange="show(this)">');}else {var selectBox = document.createElement("select");selectBox.setAttribute("name", "selectBox");selectBox.setAttribute("id", "selectBox");selectBox.setAttribute("onChange", "show(this)");}var optionOne = document.createElement("option");var txt1 = document.createTextNode("One");optionOne.appendChild(txt1);var optionTwo = document.createElement("option");var txt2 = document.createTextNode("Two");optionTwo.appendChild(txt2);var optionThree = document.createElement("option");var txt3 = document.createTextNode("Three");optionThree.appendChild(txt3);selectBox.appendChild(optionOne);selectBox.appendChild(optionTwo);selectBox.appendChild(optionThree);var customTr = document.createElement("tr");var customTd = document.createElement("td");customTd.appendChild(selectBox);customTr.appendChild(customTd);var trNode = document.getElementById("tr1");var tableNode = trNode.parentNode;tableNode.insertBefore(customTr,trNode);}function show(el){ alert(el.options[el.selectedIndex].text);}</script></head><BODY>test<form name="test" method="get"><table id="table" border="1"><tr id="tr1"><td><input type="text" value="test" name="t"><input type="button" id="button1" value="Add Select Box" onClick="addRow()"><input type="submit"></td></tr></table></form>test</BODY></HTML> Good Luck,
×
×
  • Create New...