Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. IMHO - the src attribute is pointing to a file. It does not go thru any kind of process to determine your query string appendage. When your php script builds that link it has to set the src attribute (using a random routine) to the actual filename to be displayed.
  2. Hopefully you sanitize the GET variable before using it in your query. Basic security! Also - if you do already have code you should show us the RELEVANT area that you are having a problem. Many of us don't go to other sites to see possibly malicious pages. See the Rules.
  3. Really? Your option tags don't look like they should have anything in them. echo "<option value=$row[field1]>$row[field1]</option>"; I think they s/b like this: echo "<option value=\"$row['fields']\">$row['fields']</option>"; The value attribute s/b quoted as should the indices of your array reference.
  4. I am trying to pre-edit the date field before submitting the form. I erase the bad input in my check function but I want the focus to remain on that field until a valid date is entered since it is required.
  5. How do I get the current event to do the prevent call?
  6. Ok - never mind. Made a change to use onBlur instead of onChange and it works better than expected!
  7. Ok - I have an input field that makes a call to a js function at onchange. The function returns true/false and the calling field is ready for that. Problem is the function tries to set the focus back to the input field it just edited before returning but the system continues to move focus to the next field since I pressed tab to trigger the onchange event. How does one "cancel" the tab event in that onchange handler so that the user has to fix his input before moving on?
  8. I have this json object that I created from php data. Works well so far - I can read it, search it and add new props to it. Basically I am treating it like an associative array. Here is a visual: {"key1":"value1","key2":"value2"} As I said - I can add things to this just fine. Problem is trying to remove a prop, such as dropping "key2" and ending up with just one element (property) in the object. I have the following code: // ok - remove this key from the attendees list and array var elem = document.getElementById('fld_2'); var key = elem.value; delete atts[key]; if (atts.hasOwnProperty(key)) alert(key+" has been deleted from atts"); else alert(key +" was NOT deleted from atts"); I know that I have a valid value in 'key' and I know that the property does exist before doing the delete yet when done the alert message tells me the item was NOT deleted. So - how do I do this? BTW - I am currently testing this with IE10 and I have seen in my research that IE may not(?) support delete. PS - I have also seen and tried "delete.atts[key]" which actually breaks the code. At least what I have above runs.
  9. Hmmm... The stringify thing seems to do exactly what I want.
  10. Never mind. I found out how to dislay my update object. After adding a new element to the object(array) via obj[key] = "value" I simply then assign the obj to my div innerHTML using JSON.stringify(obj). Voila!
  11. You're worried about an insert having to update multiple indices and you have a lot of inserts going on. What about the simple fact that your script wants rebuild THE ENTIRE set of indices multiple times per day?
  12. I know I marked this as 'Answered', but I have a followup question. My script receives user input that my js code adds to the object that my json code created. For debugging purposes I have made the div that holds the php array visible so I can see what my json object contains. I have managed to get the js code to add a new element to the object which I verify with the hasOwnProperty after adding it. What I can't seem to do is get the div to be refreshed with the updated contents of the object. I try to set the value or innerHTML props of the div but all it displays "[object Object]". Can I not do this?
  13. If you have established indices that are maintained (and why wouldn't they be?) then there (As I Already Said) is no need to re-create them. When a table is updated, so is its index. Simple Database Knowledge.
  14. Somewhere in your code you are probably in a loop creating new vars or arrays and trying to allocate too much memory. PS - I don't understand why ANYTHING you do to your data tables would necessitate having to rebuild ANY index.
  15. Thanks again. Case Closed.
  16. Solved! The code that I had to do a search was outside a function and therefore executed out of sequence. Thank you very much Jacques! Once again..... well, you know. OOPS - last question. Here is my search function: function keyExists(key, search) { for (k in search) { alert("checking "+k+" - "+search[k]); if (k === key) { return true; } } return false; For my test I use the Bluman code - 055 - which I can see on screen as being the first element of the array/object yet I watch search function begin with the 2nd element and finally get to the first one LAST! What's that about?
  17. Well, I thought I pieced it together but no luck. Before I begin outputting any of the html/JS code I do this: $json = json_encode($_SESSION['atts_ar']); // encode my array $json_object = htmlspecialchars($json,ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8'); Then I created a JS function: function getJsonData() { atts = JSON.parse(document.getElementById('json_data').innerHTML); alert("atts is "+atts); } which gets output as part of my web page. At the bottom of my html/web page I output this: echo "<div id='json_data' class='json_data'>"; echo $json_object; echo "</div>"; where the class is defined as visible so I can see the data which looks like this: {"055":"Bluman, Anthony","148":"Duncan, Paul",..... Then in my body tag I added an onload to call the JS function: <body onload='getJsonData()So to summarize:I created the proper json object; I buried it in my html I wrote a JS function to grab the buried data I called the function on the page load. Net result is that the alert shows that the end result is an object Is this what I should expect? And if so, how do I search this array/object based on the key elements?
  18. So - how would you suggest I get the php data into a js format and then how do I search the js formatted data?
  19. I have taken an PHP array that looks like this: $arr = ('key1'=>'value1','key2'=>'value2','key3'=>'value3'); and run it thru json_encode() to assign it to a JS var: <script type='text/javascript'> var ar = <?php echo json_encode($arr, JSON_PRETTY_PRINT); ?>; Now I am trying to figure out how to use this JS array (object?) variable and find values based on the keys in it. Basically if given a key, I want to find out if it exists in the array and what the value of that key is. Not having much luck.
  20. This code: $i = 0; while ($i < $AnswerID) { $AnswerID= $_POST['AnswerID'][$i]; ... ... has got to be part of the problem. How can you use a certain var as a control for your loop and then immediately change its value inside that loop?
  21. Why would one add an index everytime a script is run? If you WANT an index, then create it by hand and stop worrying about it. As for other problems - turn on php error checking, add your own error checking (like test if your query runs before moving on) and see what pops up.
  22. First thing would be to rewrite using mysqlI or PDO interface. Once again (for the benefit of all) MYSQL is deprecated and has been for years. That means Stop Using It.
  23. Again - which line is the error message pointing at? Also - if you only expect a value of 1 or 2 from the checkboxes, why aren't you using a radio button instead?
  24. Huh? What line is the error on? Read up on how checkboxes are handled - you don't get a $_POST element for a checkbox if it is not checked, so you will get a warning/notice because of that. Do you have error checking turned on?
×
×
  • 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.