Jump to content

etsted

Members
  • Posts

    274
  • Joined

  • Last visited

Posts posted by etsted

    Weebly

    If you give body a background color in external stylesheetbody {background-color: red;}There is nothing there that will make it target a specific page.If you a apply id ref OR class to body element you can uniquely target that page, for example using a id ref.Page1<body id="bg-color01">Page2<body id="bg-color02">Page3<body id="bg-color03">Then target those id ref to apply different color to those specific pages,#bg-color01 {background-color: red;}#bg-color02 {background-color: green;}#bg-color03 {background-color: yellow;}IF you are able to insert style element within the <head>...</head> of each individual page, then you could just usePage1<style>body {background-color: red;}</style>Page2<style>body {background-color: green;}</style>Page3<style>body {background-color: yellow;}</style>But i suspect it might be template system where you will add this specific style and it will be applied to all.

    lol i didnt notice that you had posted the same as me xD

    Weebly

    If you give body a background color in external stylesheetbody {background-color: red;}There is nothing there that will make it target a specific page.If you a apply id ref OR class to body element you can uniquely target that page, for example using a id ref.Page1<body id="bg-color01">Page2<body id="bg-color02">Page3<body id="bg-color03">Then target those id ref to apply different color to those specific pages,#bg-color01 {background-color: red;}#bg-color02 {background-color: green;}#bg-color03 {background-color: yellow;}IF you are able to insert style element within the <head>...</head> of each individual page, then you could just usePage1<style>body {background-color: red;}</style>Page2<style>body {background-color: green;}</style>Page3<style>body {background-color: yellow;}</style>But i suspect it might be template system where you will add this specific style and it will be applied to all.

  1. when i console.log the str variable it says "No suggestions", but when i try to use that statement in a if statement it doesnt work.

    var suggested_titels = ajax.responseText.split("S_E_C_R_E_T__S_I_G_N__!_|_!_|");                              for(var i =0;i < suggested_titels.length; i++){                           var space = document.createElement("BR");              var node = document.createElement("SPAN");              var textnode=document.createTextNode(suggested_titels[i]);              var check = document.createTextNode(suggested_titels[0]);              var str = document.createElement("DIV");              str.appendChild(check);              node.appendChild(textnode);             node.appendChild(space);              sQ.appendChild(node);              if(suggested_titels[0] == "No suggestions"){                  sQ.innerHTML = "";              }          }            console.log(str);

    sQ is supposed to get empty when there is not suggestions in the DB

  2. var sQ = document.getElementById("suggest_query");var suggested_titels = ajax.responseText.split("S_E_C_R_E_T__S_I_G_N__!_|_!_|");                              for(var i =0;i < suggested_titels.length; i++){                           var space = document.createElement("BR");              var node = document.createElement("SPAN");              var textnode=document.createTextNode(suggested_titels[i]);              node.appendChild(textnode);             node.appendChild(space);              sQ.appendChild(node);                            if(suggested_titels[i] == "No suggestions"){                  sQ.innerHTML = "";              }

    It seem to be working, but from my code you can see that i want to empty the div when the request equal "No suggestions", but instead it appends "No suggestions" at the back of my div, so it will contain all of the suggested terms and "No suggestions" at the end

  3. when i search for something there is always a <br> tag infront of the search term, other than that it works

    for(var i =0;i < suggested_titels.length; i++){              //nr1 += "<span onmouseover='pick_this(this.value)'>"+ suggested_titels[i] +"</span>";             var space = document.createElement("BR");              var node = document.createElement("SPAN");              var textnode=document.createTextNode(suggested_titels[i]);              node.appendChild(textnode);              node.appendChild(space);              document.getElementById("suggested_query").appendChild(node);          }
  4. well i tried this code, but it only renders a <br>. and the console.log shows <span>_</span>

    var space = document.createElement("BR");          var textnode = "";          for(var i =0;i < suggested_titels.length; i++){              //nr1 += "<span onmouseover='pick_this(this.value)'>"+ suggested_titels[i] +"</span>";              var node = document.createElement("SPAN");              var textnode=document.createTextNode(suggested_titels[i]);              node.appendChild(textnode);              node.appendChild(space);          }            document.getElementById("suggested_query").appendChild(node);            console.log(node);
  5. i tried this, didnt quite work

    
    
    var nr1 = "";          var node = document.createElement("SPAN");          var textnode = "";          for(var i =0;i < suggested_titels.length; i++){              //nr1 += "<span onmouseover='pick_this(this.value)'>"+ suggested_titels[i] +"</span>";                            textnode=document.createTextNode(""+suggested_titels[i]+"");              node.appendChild(textnode);                          }            document.getElementById("suggested_query").appendChild(node);            console.log(node);

    the console.log logs <span> <br></span>. While inside suggested_query i get all search result as one big span, and the <br> are visible

  6. i get Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node': The new child element is null. When trying to use appendChild, but if i try innerHTML it works.

    var suggested_titels = ajax.responseText.split("S_E_C_R_E_T__S_I_G_N__!_|_!_|");                    var nr1 = "";          for(var i =0;i < suggested_titels.length; i++){              nr1 += "<span onmouseover='pick_this(this.value)'>"+ suggested_titels[i] +"</span>";          }            document.getElementById("suggested_query").appendChild(nr1);            console.log(nr1);        }
  7. if i were to take away that for loop and write something like this: document.getElementById("suggested_query").innerHTML = suggested_titels[0], then it works.

    Btw the showMore is called further down;

    Search: <input type="text" name="s" size='70' id='search' onkeyup="showMore(this.value)" autocomplete="off"                                value="<?php if(isset($_GET['s'])){echo trim($_GET['s']);}?>">

    Inside a form

    and under the form is this:

    <div id="suggested_query"></div>
  8. when i try to run this code console.log says showMore is not defined

    function showMore(str){var sQ = document.getElementById("suggested_query");    var type = document.getElementById("mySelect").value;    if (str.length==0)      {           sQ.style.height = "0px";          sQ.innerHTML="";          return;      }        var ajax = ajaxObj("GET", "suggested_query.php?q="+str+"&type="+type);        ajax.onreadystatechange = function() {                if(ajaxReturn(ajax) == true) {          sQ.style.height = "145px";                    var suggested_titels = ajax.responseText.split("S_E_C_R_E_T__S_I_G_N__!_|_!_|");                    var nr1 = "";          for(var i =0;i < suggested_titels.length; i++){              nr1 .= "<span>"+ suggested_titels[i] +"</span>";          }                 }    }          ajax.send();}
  9.  $sql = "SELECT vote FROM rate WHERE username = '$username' && file_name = '$file_name'";                $query = mysqli_query($con,$sql) or die(mysqli_error());                                $row = mysqli_fetch_array($sql);                $DB_vote = $row['vote'];                //var_dump($DB_vote);                                //check to see if the user has voted on this file before                if($rate_type === "good" && $DB_vote === 1)                {                    $vote = 1;                } else if($rate_type === "good" && ($DB_vote === 0 OR $DB_vote == NULL) )                {                    $vote = 1;                } else if($rate_type === "good" && $DB_vote === -1)                {                    $vote = 0;                } else if($rate_type === "bad" && $DB_vote === 1)                {                    $vote = 0;                } else if($rate_type === "bad" && ($DB_vote === 0 OR $DB_vote == NULL) )                {                    $vote = -1;                } else if($rate_type === "bad" && $DB_vote === -1){                    $vote = -1;                }                                  $numrows = mysqli_num_rows($query);                if($numrows === 0){                    $sql = "INSERT INTO rate VALUES('','$file_name','$username','$vote')";                    $query = mysqli_query($con,$sql) or die(mysqli_error());                } else if($numrows === 1){                    $sql = "UPDATE rate SET vote = '$vote' ";                    $query = mysqli_query($con,$sql) or die(mysqli_error());                }

    I am trying to make a rate system that rate a file according to what he rated before. So when i press "bad" i get a value of -1 as expected, but then when i press "good" i get a value of 1 (stored in the DB), But it should have the value 0 as you can see in my code.

  10. why wont onmouseover work?

    I am trying to make a function so that when a specific titel is hovered over that titels name wil be put inside another div

    
    
    function pick_this(to_pick){    document.getElementById("suggested_query").innerHTML = to_pick;    } var ajax = ajaxObj("GET", "suggested_query.php?q="+str+"&type="+type);        ajax.onreadystatechange = function() {                if(ajaxReturn(ajax) == true) {          document.getElementById("suggested_query").style.height = "145px";                    var suggested_titels = ajax.responseText.split("S_E_C_R_E_T__S_I_G_N__!_|_!_|");          //document.getElementById("suggested_query").innerHTML= suggested_titels[0];          for(var i =0; i< suggested_titels.length; i++)          {              document.getElementById("suggested_query").innerHTML+= "<span onmouseover='pick_this(this)'>" + suggested_titels[i] + "</span>";          }                           }    }
×
×
  • Create New...