Jump to content

thescientist

Moderator
  • Posts

    8,682
  • Joined

  • Last visited

Everything posted by thescientist

  1. is the extra > intended here? style="fill:#0000FF;stroke-width:0;"/>>
  2. it was only meant as an example. First thing I see is your form is GET, so you need to change his example to use that. Then please provide the error message(s) and your updated PHP code after that.
  3. please provide the updated code, or update your post. It should give you a line number for the error too, which you can indicate to use which part of the code that error is happening on.
  4. not harsh at all. the same question has been asked twice in the past two days, and is probably the most frequently asked question about an error message (if they even have errors turned on) in the PHP forum
  5. An issue may be the execution of the initial infoDivs loop. try wrapping all that JS code in a window.onload function. i.e. window.onload = function(){//code goes here} the loop is happening before the HTML content is available in the DOM. Also, I noticed I made a mistake, and 'hide' should be 'none'; Aside from that, you will need to add your own debugging and test that the function is firing, that elements and variables are what you expect them to be, that the loops are running, etc.
  6. i have no way of knowing your implementation of the code without seeing the changes you've made to the code. Do you know how to log to the console so you can test variables and value to make sure you know what they are?
  7. think it through. Basically you are just using the numeric part of the ID of one element to get a mapping to another element. They key being that you need some sort of delimiter between the string and the number so you can split on it. so, taking what you have (with a delimiter added to row) <div class="row" id="row_1">Row (<a href="#" onclick="hideShow(this)">Show Info</a>)</div> <div class="row" id="row_2">Row (<a href="#" onclick="hideShow(this)">Show Info</a>)</div> <div class="row" id="row_3">Row (<a href="#" onclick="hideShow(this)">Show Info</a>)</div> <div class="row" id="row_4">Row (<a href="#" onclick="hideShow(this)">Show Info</a>)</div> <div class="info" id="info1">Info</div> <div class="info" id="info2">Info</div> <div class="info" id="info3">Info</div> <div class="info" id="info4">Info</div> we can implement JSG's suggestion //get and store all info divs ahead of timevar infoDivs = [];for(var i = 0, l = document.getElementsByTagName('div').length; i < l; i+=1){ var div = document.getElementsByTagName('div')[i]; if(div.className === 'info'){ infoDivs.push(div); }}; function hideShow(element) { var idNum = element.id.split('_')[1]; //split the passed in element and get the number //loop through the divs and show/hide the one want based on the number match of the one clicked for(var i = 0, l = infoDivs.length; i < l; i += 1){ var div = infoDivs[i]; div.style.display = (div.id.index(idNum) >= 0) ? 'block' : 'hide'; }} now of course I just wrote this, so make sure you test and debug on your own with the error console open
  8. I was just thinking the exact same thing. Maybe we just need to make a sticky for it....
  9. I would think from now on you would have taken to heart the advice we give you in everyone of your posts. You need to debug and trace your steps through your code. We tell you this everytime. Have you looked up the functions you are using on the w3schools site, or in the php manual, in particular the ones related to the error? Where are you logging/outputting your variables? I don't see any error handling, or testing to confirm that all steps of your code are actually succeeding. No offense, but this should be your first line of defense EVERY TIME. Literally every post is the same; something doesn't work, or you have an error, but there is no indication of anything you have done to narrow it down to a specific line, variable, conditional, etc. Just sayin.
  10. you should really start at the root of the problem, which is coming from mysql_query, and error check it as has been exampled to you.
  11. yes. callbacks in AJAX are generally used within the context of asynchronous requests.
  12. what do you mean by "loaded"? In order for a function to execute, you need to call it, with parens (). Your inner "wrapper" function is never executed, and thus it will never call the inner func function. Consider a readable implementation of your code. There is no need to use the ternary operator since you are not assigning the value to anything, or returning anything from the function.Also, I would not recommend using document.write, and instead write to the innerHTML property of some element on the page. But for now, let's stick with your example. var aCondition = true;var writeToPage = function(word){ document.write('The word is ' + word);}; window.onload = function(){ if(aCondition){ writeToPage('hello'); }}
  13. This issue comes up a lot around here. The function is expecting a result resource, and if doesn't get one, you get the error you are seeing. The next logical step is to work back to where that result resource came from, which is here$sql = mysql_query("SELECT * FROM user WHERE email='$user' AND password='$pass'"); if you read the documentation, you will find that if there was an error, you won't get a result resource, you will get false. http://php.net/manual/en/function.mysql-query.php False is a boolean, which is exactly what the error is telling you. At this point, you need to start and debug each step, from the connection to the DB, to the query. Nothing in your code indicates that any of these are definitely working, as you have no error handling or debugging in place. There is no reason for you or us to expect your code is just "working" because you say it is.
  14. that defeats the purpose of radio buttons. Only one in a group can be checked/selected. If they have different names, you don't get that behavior.
  15. actually, I am mistaken. The variables were already global (because you never used var in front of it), the issue was you were trying to use the value of sJSON in the second request before the first request completed and set its value.
  16. loop through them and check that at least one has been selected.
  17. declare it outside of the function scope. i.e. <script>var oJSON, sJSON;.. however, if you plan on using the value of sJSON across two asynchronous requests (with the second being dependent on the first), you would probably want to make the second AJAX request as part of the callback function of the first. (at that point it won't need to be global though).
  18. are you saying live it works in Chrome, but FF? are there any errors in the console?
  19. thescientist

    type casting

    http://php.net/manual/en/function.return.php
  20. it's not a "mode" as in something that is part of PHP or HTML; it's just part of the url, forming part a query string. "Mode" is only meaningful to the developer of the context of this application.
  21. on a side note, since AJAX is javascript, you could just post in the Javascript forum.
  22. do you actually understand what $_GET and $_POST are? If you are indeed submitting anything to the page with a form, using GET/POST, then something would be in there. If not, then there is probably something wrong with your form.
  23. are there any examples/docs available without signing up? I'm still not really sure what the concept is about.
×
×
  • Create New...