Jump to content

Irate

Members
  • Posts

    354
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Irate

  1. preventDefault() is obvious - the default action associated with an event is prevented. In case of a click on an <a> tag, you will not be redirected to another page. stopPropagation() stops the click event from propagating up to a higher hierachy element - also called "bubbling" - and prevents the click action from accidentally triggering other clicks.
  2. For this feature you can use closures to capture the state of the variable, but as .josh said, please, validate it server-side.
  3. You should be able to modify iframe content with window.frames[index], where index is an integer for each <iframe> element, starting at 0. Example. <html> <head> <title>IFrames</title> <script type="text/javascript"> window.onload = function(){ var ifr = window.frames[0]; for(var i = 0, d; (d = ifr.getElementsByTagName("body")[0].getElementsByTagName("*")[i++]); ){ alert(d.innerHTML); } }; </script> </head> <body> <iframe src="/somepath/somefile.php"> Your browser does not support iframes. </iframe> </body> </html>That would alert the innerHTML of the entire iframe, one by one. Of course, that is not a productive code, but it demonstrates my point.
  4. To add more to the above method kicken provided, strings should be immutable "objects", means that you can read their value like an array, but you cannot set the index to something else. Example. <?php $str = "This is an example string."; $splitstr = $str[0]; // "T" $str[0] = "D"; // fails echo($str[0]); // still displays "T" ?>
  5. return false; or return null; Simple, no?
  6. Did you try using <?php echo json_encode($signature) ?>?
  7. Try putting in a <meta name="content-script-type" content="text/javascript"> in your head section before the scripts, otherwise do as fastsol said.
  8. echo is a language construct unlike return (that's a statement) and is not terminating in the way return is (return is mostly used with functions to return a value which becomes the value of the function).
  9. PHP isn't a matter of browser as cyberRobot already said above. It's about client side you have to worry, PHP will always output the same data for all browsers. JavaScript, CSS and most parts of the HTML5 specification are what you have to supervise, and you always dynamically compute what CSS/JS to output with some $_SERVER sniffing (this is inaccurate, however, as the $_SERVER vars can mostly be changed), a more reliable feature is content sniffing, check which features the browser supports and then adjust the way data is displayed and what functions you can use, but that's mostly done client side. If this is a browser discussion, then Firefox gets my vote for most precisely built browser as it is built by the Mozilla Foundation which has the creator of JavaScript as CTO, so that you can most likely always count on non-standard as well as ECMAScript 5 standards being implemented. It's just that you can program in JavaScript more freely, seing as you needn't worry about every single thing. But that's just my opinion.
  10. Just do <a href="#" id="new_form">Click here to launch new form.</a><br><br><span id="formOP"></span> and in your JavaScript part, do this (easy solution with jQuery is in a spoiler below). function returnForm(){ var form = '<form method="POST" action="" name="newform"><fieldset><dl><dt>Username</dt><dd>Enter your username: <input type="text" name="username" placeholder="Username"></dd></dl></fieldset></form>'; return form; } function doForm(){ document.getElementById("formOP").innerHTML = returnForm(); return false; } window.onload = function(){ var c = document.getElementById("new_form"); c && c.onclick ? c.onclick = doForm() : return false; }; Edit: Fixed a small quotation error. Also, this is just a dummy function, you have to style and customize this code, of course.
  11. You are including a file from your own server, right? Otherwise, the server you're trying to send the request to might have set header('Access-Control-Access-Origin: http://owndomain.com'); so that only their own domain can send HTTP requests to their site and get responses. Just an educated guess, though.
  12. You can use <input type="hidden" id="my_Id" value="" name="width_input"> in your HTML page and change $('#sample2Txt').html(msg) to $('#my_Id').attr('value',msg) or something like that and then you simply query the $_POST['width_input'] your PHP script (but do guard against cases where JavaScript has been disabled by the client by checking the value of $_POST['width_input'] in your PHP script (above suggestions are based on the assumption that you are using a POST request).
  13. If you know exactly nothing about OOP, C++-based languages or basic control structures of programming languages, you're going to have a **very** hard time understanding a minified source code of an OS-script, so I **highly** recommend reading books about PHP if you don't know what I am referring to in the above few lines.
  14. PHP isn't visible to the client at all, PHP output **should** always be HTML.
  15. Why not just echo "<br />" in your script and be done with it? PHP natively supports HTML (when used in servers, not on the cli).
  16. Check again. First you refer to the id as optDelivery, but in your HTML it is named optDel.
  17. jQueryUI provides some neat animation scripts for what you're trying to do.
  18. Depends. Does the interviewer require XHTML-conform syntax? Another thing, when creating a site, it is a good practice to create a subfolder for images.
  19. You can add an onchange event with JavaScript, like... window.onload = function(){ for(var i = 0; i < document.all.length; i++) { if(document.all[i].attachEvent) { document.all[i].attachEvent('onchange',myfunction); } else { document.all[i].addEventListener('change',myfunction); } } }; With that, you add an event listener for all HTML elements which fire onchange, just that you got to define myfunction, of course.
  20. Q1. As requinix said, these functions do all very similar tasks. getTest1() returns a value, getTest2() assigns a value to a variable. If you echo both, you get the same results. Q2. If you are just interested in echoing 'Test', then getTest3() is the fastest as it doesn't inherit any object's methods, doesn't work with variables, it just straight-out echoes 'Test'. Otherwise getTest1() should be the fastest, based on approximated logical conclusions.
  21. I actually got a Uncaught MIME Error when I referenced to an HTML document (by declaration!) which only contained the script on Chrome, so I would be cautious with file extensions. You can set the MIME type of your PHP file with the header() function, though.
  22. It can be done with PHP if you force the user to submit after he selected an option. PHP is used to produce what I call "semi-dynamic" pages, dynamic in the sense that each user can see a different page, but is not forced to, and semi because it does not produce actual dynamic effects on the client. As Psycho said, dynamic client side effects (what you are trying to produce) are best done with JavaScript. If you know PHP, you will not have that much of a problem with learning JavaScript, syntax is pretty similar (besides from a few differences in variable declaring, calling methods of an object and string concatenation, but that's all minor).
  23. Good, glad you figured it out. Oh, another hint, use code tags on this forum when posting code. [code][/code] or [ic][/ic]
  24. The hosting site I use provides a cPanel with MySQL administration and upon entering phpMyAdmin and/or MySQL for the first time, you're prompted to enter a username wherein a new message appears with the account details. It is even strictly prohibited to use localhost on the site (admittedly, it's a free site so I don't expect much, but it's working fine).
×
×
  • 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.