Jump to content

RIRedinPA

Members
  • Posts

    256
  • Joined

  • Last visited

    Never

Everything posted by RIRedinPA

  1. I've inherited a project which is just a intranet document storage type of site. There's a drop down list of categories and a table that gets filled with the different documents associated with those categories. When an option in the drop down is selected jQuery captures it and uses ajax to build a querystring (a CI happy URL) and then it eventually returns a string that is the html for a <tbody></tbody> I get this back: <tr><td class='fileName'><a href='xxxxxx.xxxxxx.com/salesadmin/Education/Education-Collection-Process-and-Chargeback-Policy.doc' target='_blank'>Education Collection Process and Chargeback Policy</a><p class='fileDescription'></p></td><td class='fileExtension'><p class=doc>doc</p></td><td class='fileModed'>2010-08-10 07:52:30</td><td class='btn'><a class='btnEditLine' name='5' href='javascript:' title='Click to EDIT: "Education Collection Process and Chargeback Policy"'>Edit</a></td><td class='btn'><a class='btnDeleteLine' name='5' href='javascript:' title='Click to DELETE: "Education Collection Process and Chargeback Policy"'>Delete</a></td></tr> The href is correct, it is pointing to where the downloadable files are located. But for some reason when I roll over the links in the browser they are being prefixed with the site url: http://kopmacwwwo1.xxxxxxx.com/InternalAdmin/admin/index/xxxxxx.xxxxxx.com/salesadmin/Education/Education-Collection-Process-and-Chargeback-Policy.doc I console.log everything right up to where it is inserted into the tbody and it is correct. Is this something CI is doing and if so how do I correct it? Thanks
  2. The return is a string, right? So I should be able to do a str.IndexOf("something") on it, right? var userlinks = $(".userlinks").html(); //var indexnum = userlinks.IndexOf("Filter Records"); console.log(userlinks); if (userlinks.IndexOf("Filter Records") == -1) { ... I keep getting: userlinks.IndexOf is not a function
  3. Nevermind...apparently we are going to go with a new design...f'in designers...
  4. I can't get it to work... HTML: <div id="header"> <ul> <li> <p class="headertitle">Time Sheet Manager</p> <p> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> </p> <p>User Links</p> </li> </ul> </div> What I need: Item 1 User Link 1 Item 2 User Link 2 Time Sheet Manager Item 3 User Link 3 What I keep getting: Time Sheet Manager Item 1 Item 2 Item 3 CSS: #header { background-image: url(../images/bgHeader.png); background-repeat: repeat-x; color: #5CADFF; height: 75px; margin: 0; padding: 0; width: 100%; } #header ul { height: 75px; margin: 0 0 0 40px; padding: 0; } #header li { display: inline; height: 75px; list-style-type: none; } #header p { font-size: 1em; } #header p.headertitle { font-size: 2em; margin: 30px 10px 0 0; } I've played with a bunch of variations on this with no luck. Thanks.
  5. I solved this last night, posting the code for others. If it could be streamlined I'd love to see the comments. Thanks. function checkstuff() { var connector = "and"; //stuff to filter by var filteritems = new Array; filteritems["A"] = "one"; filteritems["B"] = "two"; filteritems["C"] = "three"; //fieldnames var fieldnames = new Array("A", "B", "C", "D"); //data var dataarray = new Array; var temparray = new Array; temparray['id'] = 1; temparray["A"] = "one"; temparray["B"] = "c"; temparray["C"] = "three"; temparray["D"] = "unused object" temparray["usethis"] = false; dataarray.push(temparray); temparray = new Array; temparray['id'] = 2; temparray["A"] = "one"; temparray["B"] = "two"; temparray["C"] = "y"; temparray["D"] = "unused object" temparray["usethis"] = false; dataarray.push(temparray); temparray = new Array; temparray['id'] = 3; temparray["A"] = "one"; temparray["B"] = "two"; temparray["C"] = "three"; temparray["D"] = "unused object" temparray["usethis"] = false; dataarray.push(temparray); temparray = new Array; temparray['id'] = 4; temparray["A"] = "x"; temparray["B"] = "y"; temparray["C"] = "z"; temparray["D"] = "unused object" temparray["usethis"] = false; dataarray.push(temparray); temparray = new Array; temparray['id'] = 5; temparray["A"] = "a"; temparray["B"] = "b"; temparray["C"] = "c"; temparray["D"] = "unused object" temparray["usethis"] = false; dataarray.push(temparray); //get count of filteritems var filtercount = 0; for(a in filteritems) { filtercount++; } //set a matchcount var matchcount = 0; //loop through the data items for(var d=0; d<dataarray.length; d++) { //set a match boolean var hasmatch = false; //define the row var thisrow = dataarray[d]; //loop through the fieldnames array for(var f=0; f<fieldnames.length; f++) { //loop through the filteritem object for(filteritem in filteritems) { //set the matchfield - could skip this and just use filteritem but the name makes more sense var matchfield = filteritem; //check for a match if (matchfield == fieldnames[f]) { //if match of field, check for a match of value var matchvalue = filteritems[filteritem]; if(matchvalue == thisrow[fieldnames[f]]) { hasmatch = true; matchcount++; if (connector != "and") { thisrow["usethis"] = true; hasmatch = false; break; } } else { hasmatch = false; } } } } //check to see if we have matched all the requested items if (matchcount == filtercount) { thisrow["usethis"] = true; } matchcount = 0; } for(d=0; d<dataarray.length; d++) { thisrow = dataarray[d]; if(thisrow["usethis"] == true) { console.log("Item " + thisrow['id'] + " matches the filter criteria."); } } }
  6. jquery has a nice form validator: http://plugins.jquery.com/project/validate
  7. I run a mysql query and get data returned which I dump into a grid layout on my page. I take that returned data and store it in a javascript object...basically I grab each row as an assoc array rowitems[fieldname] = fieldvalue (rowitems[id] = "1", rowitems['department'] = "photography", etc.) then store the array in my object gridObject[thisrow] = rowitems I have a filter form that the user can submit to filter the returned data. In essence I am trying to avoid making another AJAX call back to the database and appending the original query to get filtered results. I'm trying to see if I can do it on the client end. I capture the filter items (department, pubcode, etc.) and also how they want the results returned (AND or OR)...or is easy, match up the filter field with the rowitems array fields, then see if their values match and reset the array item rowitems[meetsquery] from false to true...the problem comes from when someone wants more than one criteria for a match...department AND pubcode... If I knew exactly how many items they would need to match it would be easy but in one case it could be department AND pubcode while in another it could be department AND pubcode AND affiliate...etc. etc. Here's the full code I am working with. (This will get simplified somewhat as I am just testing stuff now but realized that instead of pulling the original data from the html and breaking it down and putting it into my object I return it from AJAX already in a broken down state, by row and col.) $(".btnFilter").live('click', function() { //get items to filter by var filteritems = new Array(); var fieldnames = new Array(); //get connector var connector = $("input[@name='connector']:checked").val(); //get department var deptIndex = $('#department').val(); if (deptIndex != 0 ) { var department = $("#department option[value='" + deptIndex + "']").text(); filteritems['department'] = department; } var bucketIndex = $('#bucket').val(); if (bucketIndex != 0 ) { var bucket = $("#bucket option[value='" + bucketIndex + "']").text(); filteritems['bucket'] = bucket; } //make object from results gridObject = new Object(); //get all the rows var rowlist = $('li[row]'); for(var r=0; r<rowlist.length; r++) { //get the row content var thisrow = $(rowlist[r]).html(); //get all the p tags var rowitems = $(thisrow + 'p.[rowitem]'); //get field name var temparray = new Array(); for(var ri=0; ri<rowitems.length; ri++) { var fieldname = $(rowitems[ri]).attr('rowitem'); var fieldvalue = $(rowitems[ri]).html(); temparray[fieldname] = fieldvalue; //make array of field names if (r==1) { fieldnames.push(fieldname) } } temparray['meetsquery'] = false; //make gridObject row element here var thisrow = "row_" + r; //add temparray as value to object element gridObject[thisrow] = temparray; } //add the meetsquery key fieldnames.push("meetsquery"); //loop through the search items for (thisfilter in filteritems) { //here's the point where I am getting stuck - check if it is AND or OR, or is easy enough as I said, I am stuck on the AND part... } $.unblockUI(); }); NOTE: Some of the field names are weird sounding, I am working with an accountant on this project, so just go with it.
  8. I've done this before. Build a page in PHP that sets and gets session variables. Then build a function in Javascript similar to this: function manageSessionData(process, datafield, fieldvalue) { //declare returnvalue var var returnvalue; //set the querystring if(process == "set") { var querystring = "process=" + process + "&datafield=" + datafield + "&" + datafield + "=" + fieldvalue; } else { var querystring = "process=" + process + "&datafield=" + datafield; } $.ajax({ type: "POST", data: querystring, url: "lib/includes/manageSessionData.php", success: function(data){ returnvalue = data; }, async: false }); if(process == "get") { return returnvalue; } } then whenever I want to set or get a session var within JS I just call the function: //get session value for usertype var usertype = manageSessionData("get", "usertype", "null"); then you could use jquery or hard code or some other framework to insert the value into an element... $('#divelement').html(usertype); But like others have replied, going from JS directly to PHP is a closed street. You need to work around it.
  9. if I have an array like this: thisarray = new Array("this", "that", "theotherthing"); how could I go about building a conditional like so: if(thisarray[0] == thisvar && thisarray[1] == thisvar && thisarray[2] == thisvar) { //do something } the caveat is that I do not know how many items could be in thisarray. I'm a bit stumped as to how to accomplish this. Any help would be appreciated.
  10. I got a snippet of code from here that will give me the Monday of any submitted date, so if I pass 12/08/10 it'll return 12/06/10 as the Monday, which is correct. I tried to expand it to give me the Tuesday of that week: function getWeekDays($date) { $offset = ''; if( date('l', strtotime($date)) == 'Monday' ) { $offset = ''; } elseif( date('l', strtotime($date)) == 'Sunday' ) { $offset = 'Tomorrow'; } else { $offset = 'Last Monday'; } $monday = date('m/d/Y', strtotime("$date $offset")); $tuesday = date('m/d/Y', strtotime("+1 day", $monday)); return $tuesday; } I keep getting the UNIX epoch returned for $tuesday...obviously this is just confusing the crap out of me, could someone explain what it is I am doing wrong? Thanks
  11. $weekarray = array($thisdate); should be $weekarray = array($monday); Still returning 1/30/2011 for a 1/5/2011 date...
  12. I'm trying to write a function that'll give me the days of the week of any submitted date. This keep returning 1/30/2011 even though I am submitting 1/05/2011 (the Monday should be 1/03/2011)...I know it's incomplete I'm just trying to get the Monday right now function getWeekDays($date) { //convert string to date $thisdate = date($date); $dow = idate('w', mktime(0,0,0,$thisdate)); if ($dow == 1) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate), date('Y'))); } else if ($dow == 2) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 1, date('Y'))); } else if ($dow == 3) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 2, date('Y'))); } else if ($dow == 4) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 3, date('Y'))); } else if ($dow == 5) { $monday = date('m/d/Y', mktime(0,0,0, date('m'), date('d', $thisdate) - 4, date('Y'))); } $weekarray = array($thisdate); return $weekarray; }
  13. Figured it out: function getWeekDays($date) { //convert string to date $thisdate = date($date); $dow = idate('w', mktime(0,0,0,$thisdate)); $offset = ($dow -1); if ($offset <0) { $offset = 6; } $monday = date("m/d/Y", mktime(0,0,0,date('m'), date('d')-$offset, date('Y') )); return $monday; }
  14. I'm sure this is pretty simple I just can't find any examples with The Google. If I am being passed a date as a string in this format "01/06/11" how can I figure out what the current day is and then get the Monday of that week? I tried: $monday = getMonday("01/06/11"); function getMonday($passeddate) { $thisdate = date($passeddate); $weekday = date('w', mktime(0,0,0,$thisdate)); //$weekday here is 5, which works with Sunday as the first day of the week $monday = date('m/d/Y', mktime(0,0,0, $thisdate, $thisdate-(weekday-1), $thisdate); //this gave me 09-07-2010, which makes sense to some degree, obviously the code above is subtracting 4 months // so I assume I need to do something like this // $monday = date('m/d/'Y', mktime(0,0,0, month of $thisdate, day of $thisdate - ($weekday - 1), year of $thisdate)); // I am at a loss as to how to code that... }
  15. Darn it, stupid sys admin people. Changed everything from public to var and it worked fine. Thanks for the heads up.
  16. I'll double check with my admin but I am pretty positive we are using PHP 5, not the latest release but definitely 5...
  17. Thanks for that tip. I changed the code but I keep getting the error message pointing to line 5 - public $name = "";
  18. I am getting the following error: Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /Library/WebServer/Dev/classtest/lib/class_userdata.php on line 5 on this class code: class userdata { public $name = ""; public $city = ""; public $phone = ""; function setData($n, $c, $p) { $name = $n; $city = $c; $phone = $p; } function getData() { $userdata=array('name'=>$name, 'city'=>$city, 'phone'=>$phone); return $userdata; } } I thought that was a proper way to set up some class variables. (http://www.victorchen.info/accessing-php-class-variables-and-functions/). Thanks.
  19. Not sure if that made sense but here is what I am trying to do. I am dynamically building a display of database records in a grid (row, cols). Some of the cells use <select> form objects and I am using AJAX to help build them (the options in the select are stored in a db table). So my code looks like this (the return from the AJAX call is the complete <select><option value=1>...set up: ... //write cell html if (d == 1) { userdata += "<p class=\"datacell date\">" + thisitemarray[1] + "</p>"; } else if (d==2) { //make ajax call to get departments $.ajax({ type: "POST", url: "lib/getDropDowns.php", data: "thistable=departments&selecteditem=" + thisitemarray[1] + "&classnames=userdept userdatainput", success: function(data){ userdata += "<p class=\"datacell department\">" + data + "</p>"; } }); } else if (d == 3) { userdata += "<p class=\"datacell bucket\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userbucket userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 4) { userdata += "<p class=\"datacell pubcode\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userpubcode userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 5) { userdata += "<p class=\"datacell area\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userarea userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 6) { userdata += "<p class=\"datacell hours\"><input type=\"text\" value=\"" + thisitemarray[1] + "\" class=\"userhours userdatainput\" dbid=\"" + dbid + "\"></p>"; } else if (d == 7) { userdata += "<p class=\"datacell description\"><textarea class=\"userdesc\" dbid=\"" + dbid + "\">" + thisitemarray[1] + "</textarea></p>"; }//end d check 2 The problem is that this line of code: success: function(data){ userdata += "<p class=\"datacell department\">" + data + "</p>"; } does not show up on my page. I am assuming because userdata is being seen as a local variable within the function. How can I pull the data being passed from AJAX out into my script so I can use it?
  20. If I have a db with these fields: displayname, title and I run a successful query on the db, will this code: if (mysql_num_rows($results) == 0) { return "!fail"; } else { while ($row = mysql_fetch_assoc($results)) { extract($row); } return $row; } create an associative array of $var = array(array('displayname' => value, 'title' => value), array('displayname' => value, 'title' => value)...) If not, is there a way to do so, especially when I will not know the names or number of fields in a db table?
  21. I have a class that I use to do my db queries. I'm starting to work on a new project and purposely put in a query which would fail, thus returning no results, just to make sure the error trapping is working. Here's my code: function getResults($query) { $results = mysql_query($query) or die (mysql_error() . "\n\nYour request couldn't be procesed.<p>" . $query); $itemcount = count($results); if ($itemcount > 0) { $i=0; while($itemcount > $i) { $i++; $userdata = array('queryresult' => '!success', 'displayName' => mysql_result($results, $i-1, 'displayName'), 'title' => mysql_result($results, $i-1, 'title')); } } else { $userdata = array('queryresult' => '!fail'); } return $userdata; } when I print $itemcount it returns a value of 1, which forces the conditional and an attempt at parsing the results array. However, in my browser I get these error messages: 1 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 4 in /Library/WebServer/Dev/timesheet/lib/mysqlconnect.php on line 29 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 4 in /Library/WebServer/Dev/timesheet/lib/mysqlconnect.php on line 29 It seems as if it is telling me that results has both 1 and no items. Am I doing something to cause this?
  22. I solved it: <?PHP $User = $_SERVER[ "REMOTE_USER" ]; print "Your username is : $User"; ?>
  23. No, that's the problem, the login window is being generated by the browser I assume by a request from the server? I thought of putting a page up with a form and storing the username through a session but then it reverses my question, how do I pass the username/password back to apache to authenticate - the site is going to be behind a https wall. I hope that makes sense, like I said, not my area of competence. You can't get on the server until you authenticate. So either way, I need to talk to apache.
  24. This is kind of out of my realm so excuse any comments/questions that don't make sense. I am working on a internal site that will sit on a server which requires the user to use their Active Directory username and password to access. Once they authenticate the server will then load my page. Is there a way for me to get the username that they used to log in - I'll be using it to pull up their data stored in a MySQL db and configure the page for them. Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.