Jump to content

Davidammit

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Posts posted by Davidammit

  1. Thats an interesting program you've got set up.

     

    You could have the AJAX re-evaluate the entire form when the user changes one box, that way the list would be correct and you could have the submit button send the data to a different PHP file that stores the form contents to a database.

  2. How were you planning to approve the team?

     

    Would a person be doing it or would it be based off player stats?

     

    If it was based off player stats I would do it PHP side and make a code to the effect of

    if ( APPROVED ) {
    echo '<input type="submit">';
    }
    else {
    echo '<input type="button" onclick="notApproved($reason)">';
    }
    
    

     

    and then have a button on the main form that has the effect of sending all the players to the PHP file for checking and display.

     

    If they mess up the first button would still be there so they could try again. And if they didn't they could click on the submit button.

     

    If it wasn't approved they would have a button to check why. You could store the non-approval reasons on the JavaScript side or have it retrieve them somehow.

  3. oh I think I get it. You could change it so the PHP code does all the queries at once and the fields keep their values. That way if they screw up, they can change it easily.

     

    Then maybe have the PHP part generate a confirm button in with its response.

  4. No Problem.

     

    If you need to do an adding thing you could send another variable back to the PHP file along with the $q. and have it add that somehow.

     

    But I don't have much of an idea of how to get the result from it in number form so you could resend it for the next one.

  5. I just left the enters so it was easier to read

     

    fullResponse="<tr>

    <th>Code</th>

    <th>Name</th>

    <th>Club</th>

    <th>Price</th>

    </tr>";

     

    function stateChanged()

    {

    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

    {

    fullResponse=fullResponse + xmlHttp.responseText

    fullResponse=fullResponse + "</table";

    document.getElementById("txtHint").innerHTML=fullResponse

    }

    }

  6. If the Header is going to be the same every time, make it so the PHP side doesn't return that as part of the response. Put it in with the fullResponse variable

    fullResponse="<tr>
    <th>Code</th>
    <th>Name</th>
    <th>Club</th>
    <th>Price</th>
    </tr>";
    
    function stateChanged() 
    { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    fullResponse=fullResponse + xmlHttp.responseText
    document.getElementById("txtHint").innerHTML=fullResponse
    } 
    }

  7. So when you search the first time, it displays the results, but when you search it again, it replaces the results from the first one?

     

    When you use the document.getElementByID('id').innerHTML= command, it replaces what is inside the tag you referenced, so I'd make sure that the replacement includes the info from the first search, if you are indeed trying to display all the searches for the session.

     

    If you are trying to get it to continue showing the first and second results, I'd add the responseText onto a variable that stores the response.

     

    fullResponse="";
    
    function stateChanged() 
    { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    fullResponse=fullResponse + xmlHttp.responseText
    document.getElementById("txtHint").innerHTML=fullResponse
    } 
    }
    

  8. I've been having trouble with responseText returns as well. I tried to limit the response to 6 rows on the PHP page, and it worked right...on the PHP page.

     

    But then on the main page it displays all the rows instead.

     

    Then I also tried to display something in the format of

     

    <a href="LINK"> EPISODE </a> - DATE ADDED

     

    The whole thing displayed flawlessly on the PHP page, but then on the main page where it was supposed to end up, the first part displayed fine, but then the - DATE ADDED part got cut off.

     

    So I guess we are having similar problems.

  9. lol, you got that from W3Schools.com right?

     

    Thats where I've been learning from and I'd bet you could use responseXML to get specific infomation and access it by box number.

     

    According to the site you could have the PHP part return a XML style document and then access the XML elements by tag name in the JavaScript

     

    <formreturn>
      <text>
         value
      </text>
      <text>
         value
      </text>
      <text>
         value
      </text>
    </formreturn>
    

     

    Then...according to the tutorial, ur supposed to access it like this:

     

    function stateChanged() 
    { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    xmlDoc=xmlHttp.responseXML;
    document.getElementById("text").innerHTML=
    xmlDoc.getElementsByTagName("text")[0].childNodes[0].nodeValue;
    }
    } 
    

     

    Mind you I'm still pretty new at this and when I tried it myself I (for some reason I couldn't figure out) couldn't do the

    xmlDoc.getElementsByTagName("text")[0].childNodes[0].nodeValue;

    part and thus the whole thing didn't work.

     

    but when i did

    document.getElementById("firstname").innerHTML="JUST TEXT"

    It worked fine

     

    I believe I may be misunderstanding you, are you trying to change the value of forms to auto-fill out, or are you trying to retrieve information and just display it?

  10. You'll probably need to send the information they do give you to a PHP page, then get the return information from the database. If all would go to my masterplan, I would use responseXML...but I've been having a bit of trouble accessing that and responseText for that matter...

     

    You could then access specific elements by tag name and set them to be the new value of the empty cells. That is...if everything would go to my masterplan of things doing what they're supposed to.

  11. I've got a PHP file rigged up to return a certain number of responses off a MySQL Database.

     

    Here's the code:

     

    <?php
    /*
    $start=$_GET["start"];
    $amount=$_GET["amount"];
    */
    $start=4;
    $amount=6;
    
    $con = mysql_connect('localhost', 'waotaku_search', 'abc123');
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("waotaku_anime", $con);
    
    $sql="SELECT name, episode, title, added FROM animelist LIMIT " . $start . " , " . $amount;
    
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)) {
    $link="#";
    if ( $row[title] != null ) {
      $title=$row[title];
    }
    else {
      $title=$row[name] . " Episode " . $row[episode];
    }
    
    echo '<a href="' . $link . '">';
    echo " " . $title . "</a>";
    echo "<br />";
    }
    
    mysql_close($con);
    ?>

     

    That code displays this:

    http://weareotaku.x10hosting.com/recent_updates.php

     

    Rosario + Vampire Episode 4

    Rosario + Vampire Episode 5

    Rosario + Vampire Episode 6

    Rosario + Vampire Episode 7

    Rosario + Vampire Episode 8

    Rosario + Vampire Episode 9

    End of Updates

     

    Which is exactly what I want to display in the Recent Updates box of my site here:

    http://weareotaku.x10hosting.com/

     

    But instead of just displaying the 6 responses like it is on the PHP page, It displays the whole damned list. And try as I might, I cannot stop it and I have no clue why it won't display just the results I wanted;

     

    The JavaScript I used is http://weareotaku.x10hosting.com/recent_updates.js

     

    var recentHttp;
    var start=0;
    var amount=6;
    
    function slideupdates(direction, number)
    {
    switch (direction) {
      case 0:
       if ( start-number<=0 ) {
        start=0;
       }
       else {
        start = start - number;
       }
      break;
      case 1:
       if ( end+number>100 ) {
       start=95;
       }
       else {
        start = start + number; 
       }  
      break;
      case 2:
       if (number>=0 && number <=95) {
        start=number;
       }
       else {
        start=0;
       }
      break;
      default:
       alert('Not a Valid Slide Direction');
       return;
      break;
    }
    recentHttp=GetXmlHttpObject();
    if (recentHttp==null)
      {
      alert ("Browser does not support HTTP Request");
      return;
      } 
    var url="search.php";
    url=url+"?start=";
    url=url+start;
    url=url+"&amount=";
    url=url+amount;
    url=url+"&sid="+Math.random();
    recentHttp.onreadystatechange=recentStateChanged
    recentHttp.open("GET",url,true);
    recentHttp.send(null);
    }
    
    function recentStateChanged() { 
    if (recentHttp.readyState==4 || recentHttp.readyState=="complete") {
    recentDoc=recentHttp.responseText;
    document.getElementById("recentupdates").innerHTML=recentDoc;
    }
    } 
    
    function GetXmlHttpObject()
    { 
    var objXMLHttp=null;
    if (window.XMLHttpRequest)
      {
      objXMLHttp=new XMLHttpRequest();
      }
    else if (window.ActiveXObject)
      {
      objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    return objXMLHttp;
    }
    

     

    My final goal is to have arrows on the left and right side of the 'Recent Updates' header so that it will skip to the next set of updates. I thought it would be a nice little user interactivity thing.

     

    Any help would be greatly appreciated. As I am kinda a beginner at this I just have no clue whats going wrong. It seems that I have done everything correctly, except it displays incorrectly.

  12. I momentarily forgot PHP was serverside only. Here's the code

    <?php
    
    $q=$_GET["search"];
    
    $con = mysql_connect('localhost', 'waotaku_search', 'abc123');
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("waotaku_anime", $con);
    
    $sql="SELECT title, link, embed, added, MATCH(title, keywords) AGAINST('" . $q . "') AS relevance FROM animelist WHERE episode=0";
    
    $result = mysql_query($sql);
    
    echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
    
    
    
    for($row = mysql_fetch_array($result); $row != null; $row = mysql_fetch_array($result)) {
    echo '<person>';
    echo "<title>" . $row['title'] . "</title>";
    echo "<link>" . $row['link'] . "</link>";
    echo "<embed>" . $row['embed'] . "</embed>";
    echo "<added>" . $row['added'] . "</added>";
    echo "</person>";
    }
    
    
    mysql_close($con);
    ?>

×
×
  • 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.