Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About alan_k

  • Rank

Profile Information

  • Location
    New York
  • Interests
    LAMP, Web Development
  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
  • Create New...