Jump to content

joe92

Members
  • Posts

    304
  • Joined

  • Last visited

Everything posted by joe92

  1. I agree, and they already have, but it's terribly old and hasn't been updated since 2006
  2. A couple of articles on it: http://www.theregister.co.uk/2011/09/09/google_dart_web_programming_language/ http://news.cnet.com/8301-30685_3-20103843-264/google-to-debut-dart-a-new-language-for-the-web/ Do we really need another one?!
  3. If it is running once then failing it is the timeout which is failing. I would think it is because you are trying to send a vaiable through the timeout but still have it enclosed in " hence making it part of the string. Try this: setTimeout("human2(" + toDisplay2 + ")" , 500);
  4. If you could post your current code it would be a lot easier to help you...
  5. I would use a preg_replace. Not sure if you will have to use html code for the £ symbol though? preg_replace("/(£[0-9]+?\.[0-9]{2,2})/is", "<tag>\1</tag>", $title) I've assumed that you will always have at least 1 preceeding number before the decimal place and that you will always have 2 numbers after it to fall with standard currency format (i.e. 0 pounds and 0 pence will be represented as £0.00). The \1 is a backreference to the first set of paranthesis (first round brackets basically), I think $1 is also another way of calling a backreference. Let me know if it works.
  6. Hi James. Use a negative lookbehind. "~(?<!/)$pattern~" But as MarPlo said, post some more info if you'd like a better answer. What's your current regex? Try this website for some help too, http://www.regular-expressions.info/tutorial.html
  7. joe92

    preg_match help

    If the value of n is always going to be a number, you might as well put that in your pattern. Also, can you ever have a page where the value of n is nothing? If not, that may as well be in your pattern by using a plus instead of a star. preg_match('/\index.php?n=([0-9]+?)&img/si',$url, $mid); //assuming n is always a number P.s. I think you had the $url and the $mid the wrong way round too
  8. joe92

    Firefox 6

    I downloaded FF6 yesterday. My avast web rating add on stopped working as did my firebug add on and a couple of others. Straight away I went to the firebug website and there was already an option to download a firebug that works with FF6. This latest update hasn't really hindered me in any way. The avast add on still doesn't work but when I updated to FF5 from 4 it took about a week to keep up to date so I'm not too fussed.
  9. <img class="hand" src="italic.png" alt="italic" id="italic" title="Make text italic" onclick="insertTag(this);" /> Ahh, thank you so much Adam! This has been bugging me for a while now. Changed the <a> tags into an image and ran the function through that and it's sorted! haha. Thank you thank you
  10. Well that would be because you have told it to do CurrencyFormatted(number)... your sending a string, 'number', to the formatter. You need to send variable c. Secondly, you have said that 'Producttotal1'.value equals result, but declared the variable result on the next line. Hence, the variable result is undefined at the point when you are sending it back to the page. Change it to this: <script type="text/javascript"> function CurrencyFormatted(amount) { var i = parseFloat(amount); if(isNaN(i)) { i = 0.00; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); i = i / 100; s = new String(i); if(s.indexOf('.') < 0) { s += '.00'; } if(s.indexOf('.') == (s.length - 2)) { s += '0'; } s = minus + s; return s; } function totalprice1() { var a = document.getElementById('PricePerItem1').value var b = document.getElementById('Quantity1').value var c = a * b var result = CurrencyFormatted(c); document.getElementById('Producttotal1').value = result } </script> As you are calling the function CurrencyFormatted in the function totalprice1, it is good practice to write the former first in the script. It will work now. Hope this helps, Joe
  11. Google is your friend ... http://www.web-source.net/web_development/currency_formatting.htm
  12. http://www.javascriptkit.com/javatutors/round.shtml Shows how to do it very well. It's just a case of algebra.
  13. Well this is interesting! Try this too, 81.66 as price, 15 as quantity... I did a quick google search and it seems that javascript can get some simple mathmatics wrong. You will find this article interesting I think, and also relieving that your code is fine. http://www.astonisher.com/archives/bugnet/alerts/bugalert9298.html
  14. Not entirely sure what you are doing with document.form1, I haven't seen this used before? However, if you alter your html tag's to both have id's (your quantity tag doesn't have an id, just a name), one being PricePerItem1 and the other Quatity1 then you could do the following: function totalprice() { var a = document.getElementById('PricePerItem1').value var b = document.getElementById('Quantity1').value document.getElementById('Producttotal1').value = a * b }
  15. Works for me. Try updating your version of firebug or removing then reinstalling it?
  16. Hi. I am having huge difficulties with determining the start and end position of a selection of text in a text area in IE. Like with this forum I am trying to give the option for the user to click on a button such as 'quote' and it insert quote tags around the selected text if there is any or at the cursor postion. Below is one of the buttons the user can click and the text area. <a class="hand" id="italic" title="Make text italic" onclick="insertTag(this);"><i>italic</i></a> <textarea name="add_post" id="newPostText" class="postReply" onclick="storeCaret(this);" onselect="storeCaret(this);" onKeyUp="storeCaret(this);"></textarea> This is the storeCaret function. function storeCaret(textEl){ if (document.selection) { textEl.caretPos = document.selection.createRange().duplicate(); } } And the insertTag function. function insertTag(tg){ /*get the tag type*/ var tag = tg.id; if(tag == 'quote') { var tagprt1 = '[quote]'; var tagprt2 = '[/quote]'; } else if(tag == 'url') { var tagprt1 = '[url]'; var tagprt2 = '[/url]'; } else if(tag == 'bold') { var tagprt1 = '[b]'; var tagprt2 = '[/b]'; } else if(tag == 'italic') { var tagprt1 = '[i]'; var tagprt2 = '[/i]'; } /*get the textarea to insert into*/ var postArea = document.getElementById('newPostText'); postArea.focus(); /*IE route*/ if(document.selection) { if(postArea.createTextRange && postArea.caretPos) { var range = document.selection.createRange(); var range_length = range.text.length; var stored_range = range.duplicate(); stored_range.moveToElementText(postArea); stored_range.setEndPoint('EndToEnd', range); postArea.selectionStart = stored_range.text.length - range_length; postArea.selectionEnd = postArea.selectionStart + range.text.length; var selection = postArea.value.substring(postArea.selectionStart, postArea.selectionEnd); postArea.value = postArea.value.substring(0, postArea.selectionStart) + tagprt1 + selection + tagprt2 + postArea.value.substring(postArea.selectionEnd, postArea.value.length); } else{ alert('Please insert cursor in text area.'); } } /*good browsers route*/ else if(postArea.selectionStart || postArea.selectionStart == '0') { var len = postArea.value.length; var start = postArea.selectionStart; var end = postArea.selectionEnd; var selection = postArea.value.substring(start, end); var insertPoint = postArea.selectionStart + tagprt1.length + selection.length; postArea.value = postArea.value.substring(0, start) + tagprt1 + selection + tagprt2 + postArea.value.substring(end, len); postArea.setSelectionRange(insertPoint,insertPoint); } } I have it working perfectly in all browsers except internet explorer. I got the IE route from this article after searching all over google for what seemed like hours and edited sections to make it work with the rest of my function. But I just have no idea why it wont work? I think it has something to do with the range that is created (var range = document.selection.createRange() is always of 0 length no matter what is selected). What currently happens when the user clicks to insert the tag into the text area is it will place both the tags at the cursor position. If there is highlighted text, wherever you started the highlighting from is recognised as the cursor position. It will not place the tags around the highlighted text. Does anybody know why the range is always calculated as 0? Is there a better way to calculate the start and end positions for internet explorer? Any help is greatly appreciated and if there is anything that needs explaining better please tell me and I will do my best to explain it again. Joe
  17. You could use a positive lookahead. $pattern = "~<div class=\"items\">(.*)</div>(?=</div></div></div></div>)~" This should take the items div and everything after the items div up until an end div that is followed by at least 4 other divs, but will not return those 4 end divs. I haven't tested it though so please tell me if it works
  18. Thank you very much nogray, that worked a treat!
  19. I need to create a javascript function which will only do something once. For example, there is a text box with preset text in it. Onfocus wipes that content so that the user can type their own in. However, I need it to only wipe the content once so I need that onfocus to be disabled after the first time. Is there a way of doing this all in javascript? Is there a way of changing the javascript function using javascript? So that onfocus I could have something at the end of the function which then changes the onfocus event to something else. Cheers Joe
  20. Haha, it's almost like poetic justice. http://www.theinquirer.net/inquirer/news/2094940/lulzsec-takes-sun-wins
  21. This example on w3 achieves what your asking I think.
  22. I use the free Avast Antivirus, Malwarebytes, Spyware Blaster and Spybot Search and Destroy all together. Better safe than sorry My motto is do not trust anything Microsoft other than it's OS. If there is an alternative, use it.
  23. You need access to your mysql table as WebStyles said. If you have it, you can do something along the lines of: if(isset($_GET['brand'])) { $brand = mysql_real_escape_string(htmlentities($_GET['brand'])); $brand_query = mysql_query("SELECT what_you_need FROM which_table WHERE brand = '$brand'") //then print the data relevant to that specific query which will be specific to the brand the is in the GET }
×
×
  • 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.