Jump to content

codefossa

Members
  • Posts

    583
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by codefossa

  1. Why are you using $.post() but not actually sending data? The second parameter should be the post data. You may have wanted $.get(), but since you're just putting it into a container, you can use $.load().
  2. You gave no information, and no code. What do you expect? If you're not using JQuery, then Google addEventListener() and Ajax. If you're using JQuery, then look up $.blur() and probably $.post().
  3. Quote your comparison, so it's: $("a[href$=.pdf]")
  4. Something like this works. Demo: http://lightron.no-ip.org/tmp/47/ Javascript / JQuery $(document).ready(function() { function updateBinds() { $("#page a").click(function(e) { e.preventDefault(); $("#page").load($(this).attr("href"), updateBinds); return false; }); } updateBinds(); });
  5. If it's doing the same thing over and over, just use an interval, and clear it when you unhover.
  6. What you're asking is going against itself. You want to add to it without adding to it. You could use a browser like Chrome which supports Greasemonkey scripts by default, but it's not much different than just getting the GM extension on Firefox. The plugin itself does nothing except for support scripts you write in Javascript. Firefox has a script "scratchpad" by default SHIFT+F4 you can use and copy / paste your script into there and run it each time. I don't know what you want. If you want automatic script execution, you need to have a browser that supports it, or a plugin that adds it to the browser. It's not like you use a plain browser anyways, so what's the point of trying to not add one little piece to give you what you want? There are also plugins that are made for form completion. If you want to do it externally, then you would just set up a form using the same method and action as them, with the same parameters. Maybe if you actually explained what you want to do, then you could get a little more help. Oh, and if you're trying to add JS to someone elses visit to some site you don't own .. nobody here will likely help you.
  7. You can use plenty of plugins for Firefox, or if you want to use JS, you can use Greasemonkey and write a script.
  8. That would be loading it twice. I used $.get() just to do something in the click function. You would replace the whole $.get() or set $("#myDivID").html(data); inside of the function where you see the alert. Also, you probably want to change the URL of the link or define a different URL. It would be easier if you showed the code you currently have. It don't matter if you did something wrong. Showing what you've tried makes it easier to help.
  9. That's what I was trying to say when I said I would use a class. I figured you knew you couldn't use the same ID on multiple elements, so I didn't really bother to specify. But, here's a little example. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $(".myClass").click(function(e) { e.preventDefault(); $.get($(this).attr("href"), function(data) { alert(data); }); return false; }); }); </script> <a href="/index.php" class="myClass">Click Here</a>
  10. You could just do var url = $(this).attr("href"); in the click function to get the URL in the link. If different links go to different DIV's, I would probably use a class for all of the link that go to a certain DIV. It all depends on what you are doing.
  11. There are more ways to do it than I'm showing, but this should cover your need without needing to post. $(document).ready(function() { // Our URL to load. var url = "http://example.com"; /* * Option 1 * * Use the $.load() function. This will load the returned data * straight into the container. */ $("#myDivID").load(url); /* * Option 2 * * Same as option 1, but deal further with the data. */ $("#myDivID").load(url, function(data) { alert(data); // Alert the returned data. }); /* * Option 3 * * $.get() function and manually add it to the container. Usually * I wouldn't use this if I'm adding it to a container though. * Maybe if you're appending instead of replacing the data? */ $.get(url, function(data) { var append = true; if (append) { // Append the data $("#myDivID").append(data); } else { // Replace the data $("#myDivID").html(data); } }); /* * Better than a javascript: link in the href attribute of a link. * * HTML something like: * <a href="#" id="myLinkID">Click Here</a> */ $("#myLinkID").click(function(e) { e.preventDefault(); $("#myDivID").load(url); return false; }); });
  12. Here's a little example. Untested, so sorry if I mistyped or something. <?php // Not necessary, but easier to change. Defining SQL connection info. define("HOSTNAME", "localhost"); define("USERNAME", "root"); define("PASSWORD", "********"); define("DATABASE", "mysql_db"); // Connect or Die $link = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die("Failed to connect to MySQL. ):"); mysql_select_db(DATABASE, $link); // Select Database // Query the database. $sql = "SELECT * FROM `table` WHERE `this` = 'that';"; $result = mysql_query($sql); // We're done with it, so close the connection. mysql_close($link); // Loop through and do whatever with the returned data. while ($row = mysql_fetch_assoc($result)) { echo $row['this'] . " is that." . "\n"; } ?>
  13. Not too sure why I'm helping when you have no code ... but meh. Demo: http://lightron.no-ip.org/tmp/45/ HTML / PHP <form method="post" action="" id="myForm"> <div class="opt-first"> <input type="checkbox" value="red" name="color[]" /> Red<br /> <input type="checkbox" value="blue" name="color[]" /> Blue<br /> <input type="checkbox" value="yellow" name="color[]" /> Yellow </div> <div class="opt"> <input type="checkbox" value="circle" name="shape[]" /> Circle<br /> <input type="checkbox" value="square" name="shape[]" /> Square<br /> <input type="checkbox" value="triangle" name="shape[]" /> Triangle </div> <div class="opt"> <input type="checkbox" value="small" name="size[]" /> Small<br /> <input type="checkbox" value="medium" name="size[]" /> Medium<br /> <input type="checkbox" value="large" name="size[]" /> Large </div> <input type="submit" value="Show" class="submit" /> </form> <?php if (isset($_POST['color']) && isset($_POST['shape']) && isset($_POST['size'])) { echo "<div style='clear: both;'><br />"; foreach ($_POST['color'] as $color) { foreach ($_POST['shape'] as $shape) { foreach ($_POST['size'] as $size) { echo "A {$size}, {$color} {$shape}." . "<br />"; } } } echo "</div>"; } ?>
  14. Did you give it an attempt? Show your code and maybe we can figure out where you went wrong.
  15. You don't set it as a var. If you want to manage the returned data, just use $.get() like I showed above. Otherwise, why would you even be attempting that? If you really must use $.load() then make repeater the html of that div. var repeater = $("#pageContent").html();
  16. $("#pageContent").load("OrderLookup.html"); alert($("#pageContent").html()); $.get("OrderLookup.html", function(data) { alert(data); });
  17. You should use $.get() if you want to play around with the returned data. You could also $.load() into a DIV though, and read the HTML.
  18. Code boxes with formatted code would be nice. Also, for your protection, you shouldn't include your SQL information.
  19. Here's a quickly thrown together way of doing it. You can modify it to work with the for submission instead of a button click, but it's just for an example. Demo: http://lightron.no-ip.org/tmp/44/ HTML <input type="text" id="key" maxlength="10" /> <div id="status" style="width: 16px; height: 16px; float: left; background-image: url(warning.png); margin-top: 7px; margin-right: 4px;"></div> <input type="button" value="Add Key" id="submit" /> Javascript // Allow page to load before executing. window.addEventListener("load", function() { // Keep track of whether key is valid or not. var keyValid = false; var keyInput = window.document.querySelector("#key"); // Default field to blank. keyInput.value = ""; // Watch user input. keyInput.addEventListener("keyup", function(e) { // Help the user format they key. keyInput.value = keyInput.value.replace(/-/, '').substr(0, 4).toUpperCase().replace(/[^A-Z]/i, '') + (keyInput.value.length > 3 ? '-' : '') + keyInput.value.substr(5, 9).replace(/[^0-9]/, ''); // Check key validity and show icon. keyValid = keyInput.value.match(/^[A-Z]{4}\-[0-9]{5}/) ? true : false; window.document.querySelector("#status").style.backgroundImage = keyValid ? 'url(tick.png)' : 'url(invalid.png)'; }, false); // Verify Submission window.document.querySelector("#submit").addEventListener("click", function() { // Is the key valid when pressing submit? if (keyValid) { alert("Key is Valid"); } else { alert("Key is Invalid"); } }, false); }, false);
  20. As said above, you need to wait for the page to load, then execute the code. Here's three ways to do so. window.addEventListener("load", function() { // Code Goes Here }, false); function ready() { // Code Goes Here } window.addEventListener("load", ready, false); function ready() { // Code Goes Here } window.onload = ready;
  21. First thing that came to mind is he wanted to change the domain, though I've never used that. Interesting .. And would that add to the history, allowing you to go back through cached versions of the page?
  22. You don't change the URL like that. If you could, phishing sites would be quite a bit scarier than they are now. lol If you want the URL to change, you would have to reload the page.
  23. With jQuery, you would use Ajax and get the page loaded, put the return content in a DIV and use CSS to position it off the screen. Then just use $.animate() and move them to their locations. After moving it, you may want to actually put the content there (remove the style for location) so it doesn't pop out of it's place when someone resizes the browser. Remember to remove the old data or you'll end up with a huge amount of data depending on what you're going through.
  24. Something like this could work. Demo: http://xaotique.no-ip.org/tmp/43/ HTML <table id="data" border="1"> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> </table> Javascript / jQuery // Let page load $(document).ready(function() { // Global var var input = $(document.createElement("input")).attr("type", "text").css("width", "96%"); // Ask for input $("#data tr td").click(function() { // If same element, don't do anything ELSE set HTML if ($(this)[0] == input.parent()[0]) return false; else input.parent().html(input.val()); // Set value of input for editing input.val($(this).html()); // Watch for pressing enter to stop editing input.keyup(function(e) { if (e.which == 13) input.parent().html(input.val()); }); // Add input box and focus on it $(this).html(input); input.focus(); }); });
×
×
  • 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.