Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by alan_k

  1. Yes you are right. Never do this on a production site. I am just learning JS & php and did this as an exercise following "The Book of JavaScript, 2nd Edition: A Practical Guide to Interactive Web Pages". I was trying to add on to what author had left out which was a way to clear the todo list's completed items.
  2. Sorry for the delay in responding. I just want to thank every one for input and post how I solved issue. I will have to revisit using the $_POST array with AJAX cause I was never able to pass a variable thru it. Javascript: // Clear Done Items Functionfunction clear_done_items(){var xmlhttp;var temp = document.getElementById("list_section");var temp_list_name = temp.innerHTML;var str_len = temp_list_name.length;var list_name = temp_list_name.slice(17,str_len);var user_name = getNameFromCookie();if (user_name == list_name) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome,
  3. Here is function: function displayHomeInformation(user_name) { document.getElementById("loginArea").innerHTML = "<h3>Welcome, " + user_name + ". <br>" + "<a href='#' onClick='logout(); return false'>logout</a> </h3>"; displayLegalLists(user_name);} It just displays some login information for user. But forget about that I cant even get the POST array to my php page. I'm lost as to why this happening. I've verified you dont need a form to submit and create the POST array, yes? These 3 lines should create and send the POST array to my php file: xmlhttp
  4. That's what I thought by reading up on ajax, that all I needed was the xmlhttp.send. Any ideas then on why the _POST array is empty when I send it to my php file? I even tried GET and that didnt work. I'm really stumped by what I'm doing wrong here. Any input much appreciated...
  5. I'm sorry it does or it doesnt have to be submitted in form? I know i'm not getting to php file because print_r($POST) is printing out array ().
  6. I changed line to xmlhttp.open("POST","todolist/clear_done_items.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send('user_name='+ user_name); but get same exact error. $_POST array is still empty. Just to be clear I dont need the ".onreadystatechange" event handler if all I want is to pass the user_name to the php script and dont need anything back form the script?
  7. I am trying to pass a variable from a javascript function to my php file. All I do is extract the user_name from a cookie in javascript and then use AJAX to $_POST the variable to my php file for processing. I do not use a form to submit the POST variable which I have done in the past.The problem is my $_POST array is not getting passed to the php file. I've looked here and looked at several other suggestions but none work. Do you have to submit the $_POST variable via an html form? I dont think so but maybe I'm wrong. Here is the code:Javascript - function clearDoneItems() { var user_
  8. Just wanted to share the code in case some other newbie ever needs it. This stores the $id variable then calls the modal box to delete the record. Part of my trouble was I had to read up on scopes. Declaring id as var id was making it a local variable, only accessible within that function. Removing the var part makes the id variable default to a Global variable and thus accessible outside the scope of the function. Anyhow here it is and please feel free to weigh in to improve the solution. JS: <!--JavaScript for popup alert to Delete a row using Bootstrap modal --> <script t
  9. Thanks I finally got it to work as follows: js: <!--JavaScript for popup alert to Delete arow using Bootstrap modal--> <script type="text/javascript"> $(document).ready(function(){ $(document).on('click', '.delete-row', function(e){ e.preventDefault(); var id = $(this).attr('data-id'); // get id from td element and store it in $id. window.location = 'printer_delete.php?id=' + id; // call printer_delete.php with $id value to delete row. }); }); </script> PHP: echo "<td><a class='one glyphicon glyphicon
  10. I'm sorry I'm getting a little punch drunk with this one. The original code segment is <!--JavaScript for popup alert to Delete arow using Bootstrap modal <script type="text/javascript"> $(document).ready(function(){ $(document).on('click', '#del-row', function(e){ e.preventDefault(); var id = $("#delete-row").attr('data-id'); // get id from td element and store it in $id. window.location = 'printer_delete.php?id=' + id; // call printer_delete.php with $id value to delete row. }); }); </script> --> And the pos
  11. OK when I did it like this: <script type="text/javascript"> $(document).ready(function(){ $( "#del-row" ).click(function() { $( this).remove();});}); </script> That made the Delete Row on the modal disappear:( When I did this : <script type="text/javascript"> $(document).ready(function(){ $( "#del-row" ).click(function() { $( delete-row).remove();});}); </script> Modal box does nothing when I click on delete row button. I'm confused to because I dont want to delete the row on this page but I want to get the
  12. I tell you I tried like a dozen different examples and none worked. If someone could help me out here and show me the jquery I need to get this to work I would be extremely grateful.Thanx...
  13. I've been modifying my site and the script is supposed to get the id value stored in $row[id] field and then call delete_printer.php?id. This logic works fine for me modifying a record yet when doing a delete I get only the first row id for all rows on that page I try to delete. I've used this same line many times with no trouble and yet now it is broken and I cant see why. JS: <script type="text/javascript">$(document).ready(function(){$(document).on('click', '#del-row', function(e){e.preventDefault();var id = $("#delete-row").attr('data-id'); // get id from td element and store it in
  14. This was the trouble: Black_Toner_Cart_Num = :Black_Toner_Cart_Num Table was Blk_Toner_Cart_Num. Is there anyway to find these MySQL error messages like you can with PHP?
  15. I have a page that adds printer info into an Inventory tracking site. It passes form values to insert_printer.php via _$POST. I have used the following code before to insert a row with no problems and yet now it is not working. I have verified the php with a validator and that is correct. I put in a a print_r ($_POST) and the values are being passed to the insert page ok. I have looked at this thing for hours and nothing is popping out. Perhaps a new set of eyes will see it right away: $stmt = $link->prepare("INSERT INTO Printer_Inventory SET Printer_Name = :Printer_Name, Physical_Loc = :P
  16. Follow Up. I stand corrected the jquery function does style it the same way, and thanks for the heads up I had to add class=delete-row. I would be curious though if you have any experience calling the modal plugin via js and how it is done.
  17. The only thing is then will I have the styling the same? The Edit option is right before it and uses the tooltip from Bootstrap. I was wondering, I tried activating the modal thru javascript($('#myModal').modal(show) but it did not work, that is why I fell back on the attribute data-target way of activating the modal for the confirmation box. Do you have any experience using the js way and is there something there not mentioning in the Bootstrap documentation to make it work?
  18. I need to assign the data attribute data-toggle used in Bootstrap two values like: echo "<td><a class='one glyphicon glyphicon-trash' id='delete-row' data-toggle='modal tooltip' data-placement='bottom' title='Delete Record' href='#' data-target='#myModal' aria-hidden='true' data-id='" . $row['id'] . "'></a></td>"; cause this element has a tooltip and is also used to trigger a modal when clicked. However I cant get this to work. Does anyone know if this can be done and how because I see no documentation and I've tried several different scenarios all no good.
  19. I have a form that wont stay aligned when I shrink the page. The div2 will move over to the left and intrude on div1 and the button positions become all jumbled. I have been reading up on css and thought the way to go was making a wrapper div then two child divs for my input types but it doesnt seem to work. I have tried all sorts of things I have found all to no avail. Ideally I would like the elements to all shrink proportionally and stay alaigned as the window shrinks. Absent that I would at least like the elements to just disappear off screen as it shrinks with scroll bars. Any help is mus
  20. Thanks for your help. What was happening was the TT# field wasnt getting updated. After RTFM on bindValues I got it to work. For some reason bindParam didn't work.
  21. I'm trying this by following what I searched online but not working: $updt=$link->prepare("UPDATE TT_Form SET TT_NUM = :TT_Num WHERE LName = ?");$updt->execute(array($LName)); Also read further and tried this: $updt=$link->prepare("UPDATE TT_Form SET TT_NUM = :TT_Num WHERE LName = :LName");$updt-> bindParam(':TT_Num', $TT_Num, PDO::PARAM_INT);$updt->bindParam(':LName', $Lname, PDO::PARAM_STR, 15);$updt->execute(); Still no good. And all records have TT# of zero... Update 3: Here's the code that worked. please weigh in if something should be revised: $updt=$link->
  22. ok one problem solved. That "$stmt->execute();" wasn't needed. That's what you get for copying and pasting without understanding it is your doing and why. Still have the second trouble which is why I wanted to use prepared statements all along. I cant add a record with apostrophes and get the next tt number in the series. I get a zero on anything I add. Update: In experimenting this only happens if there is an apostrophe in the Last Name Field. So I assume trouble is with line: $updt=$link->prepare("UPDATE TT_Form SET WHERE LName = $LName");$updt->execute(array(':TT_Num' => $TT_N
  23. Appreciate your input and am on the road but still have two problems. 1. When I insert a record, two are created in mysql 2. if I insert a name with an apostrophe I get two plus the record has a Trouble Ticket number of zero. I keep on looking over the code but dont see why this happening. If you have the inclination I would appreciate any input as to what is going on.Here is my code so far: <?phpini_set('display_errors',1);error_reporting(E_ALL);include 'dbinfo.inc.php';$Date_Entered=$_POST['Date_val'];$FName=$_POST['FName_val'];$LName=$_POST['LName_val'];$Dept=$_POST['q4_department'
  24. Forgive me but I just want to understand this. I'm going to do: $stmt = $link->prepare("INSERT INTO TT_Form SET Date_Entered = :Date_Entered, FName = :FName, LName = :LName, Dept =:Dept , Rch_Num = :Rch_Num, Rm_Number = :Rm_Number, E_Mail = :E_Mail, Prob_Cat = :Prob_Cat, Rm_Avail = :Rm_Avail, Problem = :Problem, Tkt_Status = :Tkt_Status, Assgnd_Tech = :Assgnd_Tech, TT_Num = :TT_Num");$stmt->execute(array( ':Date_Entered' => $Date_Entered, ':FName' => $FName, ':LName' => $LName, ':Dept' => $Dept,
  25. I went with this. It works. If anybody has a solution that works more elegantly please weigh in. I guess PDO doesnt handle apostrophes on its own? <?phpinclude 'dbinfo.inc.php';$Date_Entered=$_POST['Date_val'];$FName=$_POST['FName_val'];$LName=$_POST['LName_val'];$Dept=$_POST['q4_department'];$Rch_Num=$_POST['q15_reach'];$Rm_Number=$_POST['q5_roomNumber'];$E_Mail=$_POST['q6_email6'];$Prob_Cat=$_POST['q11_problemCatregory'];$Rm_Avail=implode(", ",$_POST['q12_pleaseSpecify12']);$Problem=$_POST['q8_explainProblem'];$Tkt_Status=$_POST['Tkt_Status_val'];$Assgnd_Tech="Unassigned";$TT_Num=0;//Cl
  • Create New...