Jump to content

Irate

Members
  • Posts

    354
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Irate

  1. I see. Try to do it like this, then. function calculate() { // your code here... document.formname.Total.value = Math.round((text1+text2+text3+text4+text5)*0.14975+(text1+text2+text3+text4+text5));That should do the trick.
  2. Alright, let's crack down this "problem". What exactly are you trying to achieve?
  3. Yeah, like that.
  4. String does not have a method called round. Use Math.round(document.formname.Total.value) instead.
  5. I'm pretty sure you can configure your Flash Media Server to run on another port.
  6. #container needs to have a fixed position and needs to have a centered vertical align, then you could set the width property of #container div to 33.3% I'm not an expert at CSS, but that should be about it.
  7. Ah. Adjust this line, then. if(preg_match("@([0-3]{1}[0-9]{1}\-[0-1]{1}[0-9]{1}\-[1-2]{1}[0-9]{3})@",$line)&&(strlen($retVal)<9)&&(substr($retVal,0,9)!=substr($line,0,9))) $retVal .= $line . "\n";I'm not particularly sure about this, but this should theoretically work. Also, remove the echo before the printf function.
  8. Assuming we have a file called "date.txt" in the root directory of your filesystem. <?php $txt = file_get_contents("http://yourdomain.com/date.txt"); $lines = explode("\n",$txt); $retVal = ""; foreach($lines as $line) { if(preg_match("@(\d{2}\-\d{2}(.*?)@",$line)&&(substr($retVal,0,4)!=substr($line,0,4)) $retVal .= substr($line,0) . "\n"; else continue; } echo printf("<pre>%1</pre>",$retVal); ?> It's not been tested, though it should work. Edit: added a minor thing.
  9. The associated event for selecting <option> tags is "onchange". Assuming you are using jQuery for Ajax purposes (you really should), you could do this. $("select[name='nameID']").on("change",function(){ var current = $(this).find("option:selected"); $.post("/scriptUrl.php",{val:current.attr("value")},function(d){ current.after(d); }); });Untested because I cannot test my code just yet on my phone (refer to my signature if you need to).
  10. Check your line just after var frm = ... Your var frm has no property called contentDocument (unless it is an iframe within an iframe...), just call frm.getElementById("theTable") (you are still using a method called getElementsById() which does not exist... I highlighted the error for you).
  11. As long as the hostnames match, the SOP is out of effect. Your code has that, for example, but an iframe from subdomain.domain.com would be detected as not from the same origin as code from othersub.domain.com or even from domain.com. Like I said, the IFrame you have is from the same origin, so you can access the IFrame with jQuery("iframe").contents(), for example.
  12. Use either PHP if you can or pass dynamically computed values to the Function() constructor.
  13. It won't work if the IFrame's domain, protocol and port do not exactly match the domain, protocol and port of the site which is currently executing the script. The keyword is Same-Origin Policy to prevent malicious attacks on websites that are not your own. If the IFrame does match your domain, protocol and port, you need to access the contents of the IFrame, you can do that with the .value property (or with the jQuery .contents method).
  14. 76000 profile views goddamnit... This isn't legit.

  15. Those expressions with m/(.+?)_/ and others are regular expressions. The prefix m is for multiline mode, as dalecops pointed out previously. There are many guides to understand regular expressions, but they are pretty complex subjects and even though I've been trying to for the past months, I haven't completely understood everything about them.
  16. Your human-readable code would be something like this. "While we can still read files from this directory, loop through them; then, if it matches the expression m/(.+?)_(air)?port/ but does not match the other ones, push the current file into the array 'dirs'."
  17. WHERE AdminLevel >= 1 should do the job perfectly fine.
  18. You're welcome. Also, I noticed that 5.68...E-14 is not -0.649..., I forgot that in the first code I provided, one of the results was already being converted to an int. So, for the record, 5.68...E-14 is close to -0.649..., but not equal to it. Sorry for the confusion.
  19. The result you got in the first version is not an error, 5.6843418860808E-14 actually equals -0.64999999999998, it's just written in its exponential form. Try using the (int) statement twice, like this. $balance_due = ((int) $salesreceipt_grandtotal) - ((int) $payments_applied);
  20. My bad, I figured out the problem. The elem.style.color property is always noted as rgb value with spaces, I left out the spaces. Below script should work just fine. window.onload = function(){ var cc = document.getElementById("colorChange"); if( !cc ) { throw new Error("Element to change color was not found."); } cc.onclick = function(){ if( cc.style.color == "rgb(255, 0, 0)" ) cc.style.color = "rgb(0, 0, 0)"; else cc.style.color = "rgb(255, 0, 0)"; }; };
  21. Not using floats but integers helps. This is not a problem specific to PHP, by the way. Try using this instead. $balance_due = (int) $salesreceipt_grandtotal - $payments_applied;
  22. Assuming you have an element that looks like this. <span id="colorChange">Clicking this text changes the color of it.</span>Script below. window.onload = function(){ var cc = document.getElementById("colorChange"); if( !cc ) { throw new Error("Element to change color was not found."); } cc.onclick = function(){ if( cc.style.color == "rgb(255,0,0)" ) cc.style.color = "rgb(0,0,0)"; else cc.style.color = "rgb(255,0,0)"; }; };That's about all you need. You could use jQuery and make this a bit more simple and also being able to fire the script without having to wait for images to completely load.
  23. The window object is the global object in client-side JavaScript. All top-level variables (variables declared in the highest scope JavaScript has) are automatically properties of the global object. window also refers to the web browser's window itself and also has properties that reveal the current site's URL and some others. However, you are mistaking something in your assumption made above; the onload attribute of the body tag is fired when the body tag has completely loaded. But because you want to fire the next event when the web browser - not the body tag! - is about to be "unloaded", you register the event handlers on the window object, not on a DOM object (which represents <body onload=""> with document.body.onload, rather than window.onload). Hope this explains this a little.
  24. You don't register the handler on the <body> element but on the window object. window.onbeforeunload = function(){ if(confirm("Are you sure you want to leave this page?")) return false; else return true; };
×
×
  • 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.