Jump to content

xtopolis

Members
  • Posts

    1,422
  • Joined

Everything posted by xtopolis

  1. A possible solution... I'm not sure if this will work, but it might: So I have this cross browser code for mouse events... and you see the last part: e.target returns an element. See code, then read more. <script type="text/javascript"> function MouseEvent(e) { if(e) { this.e = e; }else{ this.e = window.event; } if(e.pageX) { this.x = e.pageX; }else{ this.x = e.clientX; } if(e.pageY) { this.y = e.pageY; }else{ this.y = e.clientY; } if(e.target) { this.target = e.target; }else{ this.target = e.srcElement; } } </script> So I'm thinking, since for a form to be in focus, an element ?has? to be selected..? It's possbile you could invoke this mouse event when you want to check and it may give you what you're looking for. Possibly <html><head><script type="text/javascript"> function getFormFocus() { var e = new MouseEvent(e); var x = e.target; } </script></head> <body onload="getFormFocus(event)"> Then from there you might be able to find out what the parent element is of the selected element in order to get the form name. For example, an input element might have the structure of ... document.Form1.input.. you may be able to backtrack that structure to get the value Form1. I do not know if it will work as you hope, but it might help. Good luck.
  2. or, <input type="hidden" value=$number name=number /> And then you could pull it with the $_GET on the next page as well.
  3. I'm not sure what you mean by trying to echo many on the next page? But by looking at your code, you aren't getting results regardless. I have some fixes you might consider below. ---------- Fixes ---------- <?php $many = "2"; switch($number) ?> $number should be changed to $many or else no SELECTS display <?php echo " <select><option name='grade1' value='4'>A</option> <option name='grade1' value='3'>B</option> ... </select> ?> <option> tags do not have a name attribute! Give EACH <select> in your code the attribute instead! --> <?php case "2": echo "<select name="grade1"> <option value='4'>A</option> ... </select>"; echo "<select name="grade2"> <option value='4'>A</option> ... </select>"; break; ?>
  4. onblur="updateStatus('statusinput')" They have a function that sets the text from a <p> or something to an input, then back as well. Basically, you call a function that sends the Ajax request in the background while making the changes available immediately to you using javascript. Javascript, Ajax, php, mysql.
  5. A php page is executed on the server it's running on. I was just saying that when you try to call a page that's not running on the same server as the page you're on, you usually get security warnings that stop you. The work around is to have your ajax call a php page on your server, and have that page call the php page on the other server since php doesn't complain about getting data from remote servers.
  6. About Security Apache Solution Other solution: Ajax call to YOUR server. Your server's php file does a cURL or fopen or w/e to access the site instead, prints the same results you would want to gather off the remote site on your local page. You get the same data, and handle accordingly. The bypass is that your server opens the other server instead of making javascript do it which usually ends up with the security alerts.
  7. <tr> <td><a href='addcart.php?item_selected=<?php echo $itemid; ?>' onclick="show_it()"><img src='addtotrolley.bmp' border='0' /></td> </tr> Notes: -I changed your link a bit. I had it only echo the var at the end. -I added the onclick event to your link. Simple it's like this: <a href="site.php" onclick="function()">LinkName</a> -addtotrolley.bmp, consider resaving this picture as a jpg, the filesize is much better, making your pages load faster. -you had a bbc code [/url] in there.. I took it out since I didn't see the starting one. As for a 'popbox', im not sure what you mean. You can popup an alert using the alert() function. This is that box that you can only click ok to. Or you can open a new window and resize it accordingly. This is with the window.open function. Hope that points you in the right direction.
  8. <?php if (isset($_SESSION['valid_user'])) { $username = $_SESSION['valid_user']; } echo "You are logged in as $username"; ?> Set username = to the session var., or just echo $_SESSION['valid_user'];
  9. There are security problems loading pages from another domain through AJAX. The trick is to have your server load them instead. Just search about it.
  10. AJAX stands for "Asynchronous Javascript And XML". Javascript sends a request (in the background) to the server (like a normal page would). The server picks it up and handles it in the appropriate language (ie: server running PHP obviously handles PHP code). Server outputs results and sends them back. Javascript listens for that return text(or XML) and handles it accordingly (display on the page that requested new info, or just make database updates) So basically "no". The Javascript part of AJAX sends request to the server, and the server interfaces with mysql and returns the results if any.
  11. <div id="myDiv"></div> document.getElementById('myDiv').innerHTML = XMLHttpRequestObject.responseText; innerHTML changes the entire content between the tags cited by the ID of the element.
  12. if($_GET['instrument'] == ". $row['instrument'] ."){ echo "selected=\"selected\""; } to if($_GET['instrument'] == $row['instrument']){ echo "selected=\"selected\""; } No double quotes + . around the $row['instrument']
  13. SELECT DISTINCT * FROM mytable ORDER BY instrument ASC Or use DESC for descending. Try that.
  14. Actually I don't understand it either. I would try coding it a different way if you can think of one. Sorry I couldn't be much help.
  15. http://us2.php.net/features.commandline Yep, php from the command line (can be executed from wWW scripts)
  16. Example This is a VERY basic example. All I really do is take the current innerHTML and assign it to a var "x". Then I get the value of the shout they want to enter as well as some other details (username), and then put that info into the formatting that you have. Now, here's the kicker: -If you use javascript to display the message, it's pointless to have the page refresh (like it would on a form submit)... So you may want to make it an ajax call to post that data to the shoutbox database, and show the message the client entered right away only to them. Otherwise you obviously wouldn't need to add their message since it would display all messages on page refresh. For that to happen you'd have to put some more logic into it in order to hide the form controls after submitting or something so they don't spam it. ~Ajax "Live" chat: This is easier said than done. There is no way for the browser to know when new content is available on it's own (this is how HTTP works, can't control it.) You might have a javascript timer running that checks for new messages every x seconds, but that has a disadvantage as well. Say you have 5000 people on your site, that means you have 5000 people asking for new data that may not even be new! Very bad for bandwidth. Solutions: Set some sort of checksum to check to determine if new posts have been made (saves bandwidth). Check the checksum first, then only if it's different get messages and display them in the shoutbox div. Also, on the timer that checks if new content is available, if there isn't, set the next check to wait a few seconds longer (called graceful decaying), and reset it back to checking at the same interval if new content is found. There are other ways, such as flash applets etc which use sockets, but I don't have knowledge of these. Anyway, hope my example and info helps you enough to get you on the right track. Sight looks decent, I kinda like the blue. Good luck. I'd love to help with the complicated ajax chat, but I have a big project I need to finish before I can have any fun..QQ
  17. Nexy, Are you trying to do a 'live' shoutbox where it polls the server for new shouts and updates when they appear (for everyone that can see the shoutbox). Or are you just trying to show the addition to the shout to the ONE person that added it right away? Meaning, I enter a post and it adds it to the shouts, but no one else sees it until they reload the page. It seems with the 'onchange' function you are looking to show ALL changes made and refresh them for everyone to see, am I right?
  18. Divs have an "innerHTML" property, not value. Be aware that innerHTML replaces ALL data between the <div></div> tag you change.
  19. http://www.onjava.com/pub/a/onjava/2005/10/26/ajax-handling-bookmarks-and-back-button.html?page=1
  20. Error: too much recursion http://www.google.com/search?q=javascript+too+much+recursion&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a Google it
  21. Hi, I am writing a site where users can login and are given access to files based on their credentials. These files are placed in their separate subdirectories by a unique name in order to allow regular FTP access to these files should the user prefer not to use the site. I am writing an admin option to allow creation of new directories for when we bring on new customers. The structure of each unique directory is: [uniqueName] [files] +uniquefile I can create these fine in PHP, my issue is however, is there an easy way to roll back changes should any of these steps fail. Say it didn't successfully create the unique file, I would want it to display an error, and have to retry the whole operation. Is there any easier way to do this besides checking at the end that everything exists, and if not, attempting to delete it? Another question is, if I use a try/catch blow and throw an exception, does the execution of that code stop and return to outside the try/catch statement and continue? example: Layout code try/catch make a folder more layout If an exception is raised, would it continue to display the rest of the layout even though it would be after the statement that would raise a (fatal possibly) error?
  22. The code can be found by viewing the source of PHP Freaks. If you want to see it without the fat, look: Here javascript:void(0) is actually a null thing. It basically gives the <a> thing no where to go, making it clickable but without the risk of it going anywhere. What actually makes the smiley insert is the call to a javascript function (on this board called: replaceText) which attempts to insert the smiley's equivalent BBC text " " into the text area where your last caret position was. (the caret is the blinking | that you see while typing). Read through their code and you'll understand a little bit.
  23. I copied/modified a mysql database class from a book I bought on PHP/MYSQL (Sitepoint) The class is this: You instantiate it via: $db = new MYSQL('HOST','USERNAME','PASS','DATABASENAME'); <?php //MYSQL class MYSQL { var $host; var $user; var $pass; var $dbname; var $dbConn; //constructor function MYSQL($host,$user,$pass,$dbname) { //assign vars to local vars $this->host = $host; $this->user = $user; $this->pass = $pass; $this->dbname = $dbname; //connect to DB $this->Connect(); } //Connect to DB function Connect() { //connect if(!$this->dbConn = @mysql_connect($this->host, $this->user, $this->pass)) { trigger_error("Could not connect to Database."); } //select db if (!@mysql_select_db($this->dbname)) { trigger_error("Could not select Database"); } } function &query($sql) { if (!$queryResource = mysql_query($sql, $this->dbConn)) { trigger_error("Query Failed: " . mysql_error($this->dbConn)); } return $queryResource; } function checkExistsOne($sql) { if (!$queryResource = mysql_query($sql, $this->dbConn)) { trigger_error("Query Failed: " . mysql_error($this->dbConn)); } $howmany = mysql_num_rows($queryResource); return $howmany; } }//mysql class ?> If it's still not working, tell me WHAT part isn't working, not that it still isn't working...
  24. Appreciate the reply. That site has awesome inspiration as well. However, I'm not willing to pay as I'd rather learn to code it myself. Thanks for turning me on to that page though, it gave me enough info that I know I can use an xml sheet to drive the slideshow... just need to work on the appropriate AS3. I'll mark this topic solved though. Thanks.
  25. SELECT id,siteurl,hits_in FROM `yourDB` WHERE hits_in IN (SELECT hits_in FROM `yourDB` ORDER BY hits_in DESC) ORDER BY RAND() LIMIT 5 5 minutes, google. Wrong forum board. You're welcome.
×
×
  • 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.