Jump to content
Larry Ullman's Book Forums

mccoy81

Members
  • Posts

    20
  • Joined

  • Last visited

mccoy81's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Yah sorry, I figured it out though. Some of the urls had www and some didnt that was storing different cookies. I am having one other problem that you might be able to help me with. I am using the Paypal REST api system, The sending and receiving from that is working fine. The problem I am having is that it seems as though my $_SESSION variables are disappearing when I am redirected back from Paypal. I am getting a undefined variable error when attempting to use the Session variables on the page the customer is redirected to. I need the session variable $_SESSION['order_id'] so I can retrieve the transaction id (stored in the db) to execute the payment. Any ideas?
  2. Hey everyone, I am having an issue with the cookie situation on the shopping cart and wish list pages. They work fine when it comes to adding items to the cart and moving them back and forth between the cart and wish list. The problem comes when I try to access the cart directly, without adding or updating or moving. It is using the same cookie for the other actions but if I go to the cart on its own it redirects me to an empty one. I figured out that it was a cookie problem as I had it echo the $uid instead of redirecting and I found that the cookie is different when you try to access the cart from the one that was created when you add an item to the cart. This is all happening without closing the browser so I am confused as to why it is not finding the $uid stored in the cookie and is instead creating a new one when I try to access the cart on its own. Any ideas?
  3. HI Larry and fellow forum members, First of all I love your books, they have taught me so much about website design. Now I have found a pretty big error that I do not know if you have found or not. On the stored procedure add_customers in the second example you have the phone number column set as an INT. After testing my site and wondering where the error was I found out that: 2147483647 is the largest int value for mysql. so any phone number you try to insert that is larger than that number comes up as that number (most will be). So I just switched the column and the stored procedure to a BIGINT and the problem is fixed. I just thought if you and your members did not know that yet it would be a good thing to let everyone in on.
  4. For some reason, if there was an error and (hidden) was true which causes the form to prevent Default when I go to click the submit button again nothing happens. That is fine for this situation as I am using Javascipt to prevent bot submition of the forms but If I was evauating it for actual clients I would need them to be able to submit the form again after changes.
  5. Hi Yeah I had the html in a form I just didnt put in on here but you were right I had the id of the button instead of the form tied to the onsubmitt. My only other question is how to reset the onsubmit once it has been used and changes have been made to the form so it can be submitted again?
  6. Ok, I cant for the life of me figure out how to read an input variable and if there is something entered show a div that I have hidden. I have chosen to go this route as I am very comfortable with the showing and hiding of divs but for some reason this code is not doing its job. First is my html: <div class="quote_submit"> <input id="hidden" name="hidden" type="text" class="basic_input" value="" placeholder="web development" > <div id="error">This form is not for you!</div> <button id="main_submit" class="main_submit" name="main_submit" type="submit">Submit</button> </div> and the corresponding javascript: function checker(e) { 'use strict'; // Get the event object: if (typeof e == 'undefined') e = window.event; var hidden = U.$('hidden'); var error = U.$('error'); // Check to see if hidden input has been filled in if (hidden.value.length > 0) error.style.visibility = 'visible'; // Prevent the form's submission: if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } return false; } // End of checker() function window.onload = function() { 'use strict'; U.addEvent(U.$('main_submit'), 'submit', checker); }; Is there a reason that this code would not be working when there is text entered in the input? I am trying to have it prevent the submission of the form and show the hidden div IF there is something in the input otherwise just submit the form to the corresponding php script.
  7. Hello, I am having issues inserting text into an empty div when a certain criteria is met. I have a div with an id of error and I am attempting to use the setText via the U variable. Here is my code: var U = { // For getting the document element by ID: $: function(id) { 'use strict'; if (typeof id == 'string') { return document.getElementById(id); } }, // End of $() function. // Function for setting the text of an element: setText: function(id, message) { 'use strict'; if ( (typeof id == 'string') && (typeof message == 'string') ) { // Get a reference to the element: var output = this.$(id); if (!output) return false; // Set the text if (output.textContent !== undefined) { output.textContent = message; } else { output.innerText = message; } return true; } // End of main IF. }, // End of setText() function. // Function for creating event listeners: addEvent: function(obj, type, fn) { 'use strict'; if (obj && obj.addEventListener) { // W3C obj.addEventListener(type, fn, false); } else if (obj && obj.attachEvent) { // Older IE obj.attachEvent('on' + type, fn); } }, // End of addEvent() function. // Function for removing event listeners: removeEvent: function(obj, type, fn) { 'use strict'; if (obj && obj.removeEventListener) { // W3C obj.removeEventListener(type, fn, false); } else if (obj && obj.detachEvent) { // Older IE obj.detachEvent('on' + type, fn); } }, // End of removeEvent() function. // Function for creating an Ajax object: getXMLHttpRequestObject: function() { var ajax = null; // Most browsers: if (window.XMLHttpRequest) { ajax = new XMLHttpRequest(); } else if (window.ActiveXObject) { // Older IE. ajax = new ActiveXObject('MSXML2.XMLHTTP.3.0'); } // Return the object: return ajax; } // End of getXMLHttpRequestObject() function. }; // End of U declaration. // Add error message if a certain input box is filled in function checker(e) { 'use strict'; // Get the event object: if (typeof e == 'undefined') e = window.event; var hidden = U.$('design_hidden'); var error = U.$('error'); // Check to see if hidden input has been filled in if (hidden) U.setText(error, 'Sorry this form is not for you!'); // Prevent the form's submission: if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } return false; } // End of checker() function window.onload = function() { 'use strict'; U.addEvent(U.$('main_submit'), 'submit', checker); };
  8. Those are the ids of the links. Sorry forgot to post them
  9. Hello, I am having a hard time with ajax. All I am trying to do is retrieve a list from my database via php (I am very proficient with php) but I when I click the links that are suppose to call the function with ajax in them nothing happens. Firebug is not giving me any errors either so I am confused. Here is the code that I am using the html first then the javascript: HTML - where I want the list printed - <div id="reviewsList"> <div id="staterr"> </div> <div id="statehr"> </div> </div> Javascript - I have included the utilities.js on the page var reviewsList = U.$('reviewsList'); var staterr = U.$('staterr'); var statehr= U.$('statehr'); function openRR(e) { // Get the event object: if (typeof e == 'undefined') e = window.event; // Add the data attribute value to a variable var stateRr = U.$('rr').getAttribute("data-state_rr"); // Hide the reviews div reviews.style.visibility = 'hidden'; // Make sure the staterr div is not already open if (reviewsList.style.visibility == 'hidden') { // Show the state div reviewsList.style.visibility = 'visible'; // Create the AJax object, if that hasn't yet been done: if (!ajax) { ajax = U.getXMLHttpRequestObject(); ajax.onreadystatechange = handleAjaxResponse; } // Perform an Ajax request: ajax.open('GET', 'ajax/stateList.php?rrid=' + stateRr, false); ajax.send(null); } // Prevent the link's execution: if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } return false; } // End of the openRR() function. // Function called when the getBidsAjax call is made: function handleAjaxResponse() { // Check the readyState: if (ajax.readyState == 4) { // Check the status code: if ( (ajax.status >= 200 && ajax.status < 300) || (ajax.status == 304) ) { // Parse the response: var stateReviews = JSON.parse(ajax.responseText); // If data was returned, update the table: if (stateReviews) { var links = '<ul>'; // Loop through the data: for (var i = 0, count = stateReviews.length; i < count; i++) { links +='<li><a href="http://www.top-ten-travel-list.com/' + stateReviews[i].link +'" >' + stateReviews[i].name + '</a></li>'; } // End of FOR loop. links +='</ul>'; // Print the list if (stateHr) { document.U.$('statehr').innerHTML = links; }else{ document.U.$('staterr').innerHTML = links; } } // End of stateReviews IF. } // End of status IF. } // End of readyState IF. } // End of handleGetBidsAjaxResponse() function. window.onload = function() { 'use strict'; U.addEvent(U.$('rr'), 'click', openRR); U.addEvent(U.$('hr'), 'click', openHR); };
  10. I figured out what the problem was for some reason I had ad.style.display set up as class in the html so I changed that to an id and it works now.
  11. I tried removing the href for testing purposes and firebug is giving me an error saying that "e is undefined" which doesnt make sense to me as I thought thats what was happening with this line if (typeof e == 'undefined') e = window.event;
  12. I made the changes but the link is still followed. I have firebug but it will not give me information on this error as when I click the link to see what if there is an error it goes to the new page and firebug clears the content because a new page as been loaded.
  13. I have read through the book and am attempting to use some of the information for a site I am working on. Sticking with progressive enhancement I have kept the urls in the href attribute and added ids to each of my links. My problem is that when I click the link it is following that link instead of the javascript. Here is my code if you could please help me figure out what the problem is. var connectLink = U.$('connectLink'); var reviewsLink = U.$('reviewsLink'); var attractionsLink = U.$('attractionsLink'); var aboutLink = U.$('aboutLink'); var toptenLink = U.$('toptenLink'); var content = U.$('content'); var ad = U.$('ad'); var connect = U.$('connect'); var reviews = U.$('reviews'); var attractions = U.$('attractions'); var about = U.$('about'); var topten = U.$('topten'); function openConnect() { 'use strict'; // Get the event object: if (typeof e == 'undefined') e = window.event; U.$('close').onclick = closeContent; // Close the other links if they are currently open if (reviews.style.visibility == "visible") { reviews.style.visiblity = 'hidden'; }else if (attractions.style.visibility == "visible") { attractions.style.visiblity = 'hidden'; }else if (about.style.visibility == "visible") { about.style.visiblity = 'hidden'; }else if (topten.style.visibility == "visible") { topten.style.visiblity = 'hidden'; } // Open the connect div content.style.visibility = 'visible'; connect.style.visiblity = 'visible'; ad.style.display = 'block'; connectLink.onclick = null; // Prevent the form's submission: if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } return false; } // End of openConnect() function window.onload = function() { 'use strict'; U.addEvent(connectLink), 'click', openConnect); };
  14. I am using alot of the code when creating my forum and I am having an issue I can't seem to figure out. How can I change or add a preg_replace to validate the body of a forum post and create a link when one is entered by a registered user? I want to be able to do this but still prvent against XSS attacks.
  15. Hello, I am trying to get a download box to pop-up and ask to save as for a zip file in the same window. The file being downloaded is based on user input of a download code that was sent to them in their email. I have everything working as far as validating their input but how do I force the download box to pop up after their input has been looked at and the correct file has been chosen? I have tried using header but that will only work if I redirect them to another page. I would like the box to pop up like I have seen on other site where a file is downloaded. Is this something I can do in php or do I need to use javascript? Also can anyone lead me in the right direction as to the code I would need to accomplish this? Thanks for your help ahead of time.
×
×
  • Create New...