Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Just use jQuery.ajax to load the file -- be sure in your case to turn off caching.
  2. He's not submitting joinid, it's join[id] - an array.
  3. Are you wanting to do this as the page loads, or when an event is triggered?
  4. openWYSIWYG is not an editor for code, it's for those rich-text textareas you see within web pages. There's a demo here.
  5. Ah yes. I didn't take too much notice of what the contents of $filename were before, but later in the code you're separately adding the extension: Either add the extension when you originally define $filename (removing it from lines like above) or just do the same for the file_put_contents() call.
  6. JS thinks it's an array instead of the (string) name of the element. What you can do in JS though is access object properties like an array, so instead of: document.submitform.textarea[] Use: document.submitform['textarea[]']
  7. Place it outside of your isset() check for $_POST['join']. If it weren't getting there before, placing a var_dump() within it won't make any difference.
  8. On the second page though you're making a new request, a brand new 'document' in the eyes of the web browser. You need to tell the browser what resources are needed in this document, so that it can include them. Caching is handled separately from that, and prevents the browser having to re-download the resources each time. While you might see benefits to preserving resources without having to explicitly include them on subsequent pages, you don't need every resource on every page and you it would make maintaining/removing them a nightmare. It's easier to say what is needed than what's not, and obviously makes more sense to do it that way.
  9. Debug the $_POST array. Use var_dump to check the values it contains...
  10. Just use file_put_contents. You already have the contents ($csv_output) and the file name ($filename) defined.
  11. Anything that's just basic string replacement, use str_ireplace() -- or str_replace() if you can, as it's faster. If there's multiple replacements of course you'll need to vary things slightly, so that you can specify the match and the replacement for each. Best way would be to define an array, where the keys are the matches and the values are the replacements: $replacements = array( // Key => Value 'Hello' => 'Welcome', 'Hi' => 'Welcome', ); Then you can use the array_keys and array_values functions to pass in the correct values to the replace function: str_ireplace(array_keys($replacements), array_values($replacements), $string); That would be easier than trying to maintain two arrays. Anything that's beyond the complexity of simple word replacement though would possibly need to be done using a regex, for example switching the order of two words next to each other: preg_replace('/(word1) (word2)/i', '$2 $1', $string); However don't forget about the host of other string functions available, as they're generally always faster than regex alternatives.
  12. Ah.. Then you shouldn't be using a regular expression like that. /(Hello).*?(Hi)/is This would only replace a string that contains both "Hello" and "Hi", in that order, and anything in the middle of the two would be lost. What you would do in that situation is: /(hello|hi)/is That would match "hello" or "hi" (case-insensitively since you have the 'i' flag') and replace them individually. However a regular expression isn't required for such a replacement, you can just use str_ireplace: $matches = array('hello', 'hi'); $replacement = 'Welcome'; echo str_ireplace($matches, $replacement, $string);
  13. Well with your code, and $string set to "Hello. Hi", that's what happens? Where do you define $string?
  14. In what context are you needing this? MySQL has date functions built-in that would allow you to do what you want: DATE_ADD(`date_column`, INTERVAL 2 HOUR) Edit Or when used with a string: DATE_ADD('{$date_var}', INTERVAL 2 HOUR)
  15. What are you expecting the output to be? Your replacement for the entire regex match is "Welcome" - the words won't be replaced individually and the text in-between will not be preserved. If you are just replacing words case-insensitively, then you should use str_ireplace. If not, give us some examples of the input and output strings you expect.
  16. Sorry are you talking along the lines of caching, or using the same <head> code without having to repeat it in each file? ...Or something else?
  17. You didn't just provide the CSS and JS though. You gave us a couple hundred lines of random HTML to scan through, with no explanation as to what's where and full of lines like: <font face="arial, helvetica" size"-2">Free JavaScripts provided<br> Anyway it doesn't matter now. I forgive you.. You need to post the renderQuiz() function though (check line 182 of your HTML) so we know how the CSS styles are applied to the HTML.
  18. You're getting an empty string back because the opening "<" is making PHP think it's a HTML tag. If you want to encode the characters you should use htmlspecialchars or htmlentities - filter_var() will filter it out completely.
  19. Yeah, just work out "coreHrs" after you've defined the other variables. Although I'm not sure why you have art in there? The code I gave you before would mean art_value contains the value, however isn't that "hours", "minutes" or "seconds" anyway?
  20. You're trying to use variables that haven't been defined yet: var coreHrs = noFrames * art * coresTest; var noFrames = 1800; [...] var coresTest = document.getElementById('coresintest').value; [...] var art = document.getElementById('art');
  21. Your posts are full of contradiction. Re-read your first post. You tell us what you want doing, give us your existing code, and then say thanks. How is that not a request for us to do it? Even if that wasn't the intention, you still unintentionally gave off that impression. You originally say you want to save yourself time and cut corners, and that you've only acknowledged the source code. Now it's 2 hours endlessly trying to figure it out? As I said full of contradiction. If you post the relevant code I'm sure we can sort it out quickly, but why should I spend time picking through the code to find the root of your problem, so that I can save you the time? It's a perfectly fair point.
  22. http://www.phpfreaks.com/page/rules-and-terms-of-service See rule #12 and guideline #3.
  23. Yep. Also getting the value of a select box isn't like getting the value of a text input. The options are contained within a child object of the select element called "options", and the .selectedIndex property contains the array index of the currently selected option. So you need to combine the two to get the selected option's value: var art = document.getElementById('art'); var art_value = art.options[art.selectedIndex].value; With that code, you would want to use art_value in the switch expression.
  24. You've blatantly just downloaded this with little to no knowledge of JavaScript/HTML/CSS, and now you want us to customise it for you. If you have a specific problem and can point out the relevant code, I'd be happy to help. I'm/we're not just going to do it for you though...
  25. Where do you define art?
×
×
  • 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.