Jump to content

Spunky

Members
  • Content count

    342
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Spunky

  • Rank
    Member
  • Birthday 09/29/1989

Contact Methods

  • Website URL
    http://www.christineschoell.com
  • ICQ
    0

Profile Information

  • Gender
    Female
  • Location
    Illinois

Previous Fields

  • Languages
    XHTML, CSS, PHP, MYSQL, Javascript, Jquery

Recent Profile Visitors

4,707 profile views
  1. Spunky

    Using CSS Selectors

    If only the code in the JSFiddle was a copy-paste of my exact code. But alas, it is not: At best I would have avoided my last response, avoiding yours as well. However, I am doing my best to replicate the HTML markup that I am using in here to figure out what exactly is the problem here. Clearly it is still something else. I will see what structure I am missing from my actual code and see if I can figure this out.
  2. Spunky

    Using CSS Selectors

    I don't see it. I Suppose if I did notice it, I wouldn't be here. 🤔 Are you referring to the YesNo_radio class? Malformed as in a typo?
  3. Spunky

    Using CSS Selectors

    More specifically, the CSS may even be targeting the first instance of .formContainer as well. I've updated the code for another page where table.YesNo_radio doesn't appear in the first .formContainer and none of them are being targeted. Here is a JSFiddle of the example I provided above though: https://jsfiddle.net/juanL52z/4/ Notice how the 2nd instance of the 2nd <span> does not receive the CSS. That's the problem.
  4. Spunky

    Using CSS Selectors

    I'm trying to use CSS selectors to target specific elements throughout my page and I can't figure out proper use to target everything I am trying to. Here my HTML, trimmed for simplicity (I hope): <div id="formWrap"> <div class="formContainer"> <div class="row"> <div class="column"> content </div> <div class="column"> content </div> </div> <!-- more rows --> <div class="row"> <div class="column"> content </div> <div class="column"> <table class="YesNo_radio"> <tbody> <tr> <td> <span> content </span> </td> <td> <span> content </span> </td> </tr> </tbody> </table> </div> <!-- column --> </div> <!-- row --> <div class="row"> <div class="column"> content </div> <div class="column"> <table> <tbody> <tr> <td> <span> content </span> </td> <td> <span> content </span> </td> <td> content </td> </tr> </tbody> </table> </div> <!-- column --> </div> <!-- row --> <!-- more rows, possibly with more tables --> </div> <!-- formContainer --> <div formContainer> <!-- more rows, some with tables --> </div> <!-- more formContainers, with rows, with tables --> </div> <!-- formWrap --> Here is my CSS: #formWrap .formContainer .column table.YesNo_radio td:nth-of-type(2) span{ margin-left:15px; } So basically the HTML is wrappers around rows and columns that I use to layout the content. Trickled in are tables and some of those tables use a special class that need to be treated different: specifically I want the <span> to be treated differently. For every table.YesNo_radio I need the 2nd span to have margin-left:15px;. However, using the CSS shown, it only targets the first .table.YesNo_radio's <span>. I've tried other variations to the CSS such as being even more specific (by including the <tbody>, <tr>), less specific. I think at first I had the selector elsewhere but I feel like I've determined that logically, being on the <td> makes the most sense. CSS selectors can be very complex, so I'm guessing this is just a matter of creating it just right and I just can't figure out the magic combination. I'm hoping someone could help me out in figuring out how to position the selector/which selector to use.
  5. So, I am trying to set up what I am calling a "Guided Tour" which uses CSS tooltips/popups to explain various parts of the page that they are on. I want the "tour" to run automatically, but also give them the ability to pause and continue it at any time, as well as go to the next and previous tip as needed. I'm finding this to be a bit more complex than originally anticipated. Mostly because it seems that using setTimeout() inside a for loop isn't that straight-forward. Let's start with my code: var startG = document.getElementById("startGuide"); var guidetips = []; guidetips[0] = document.getElementById("tip1"); guidetips[1] = document.getElementById("tip2"); guidetips[2] = document.getElementById("tip3"); guidetips[3] = document.getElementById("tip4"); guidetips[4] = document.getElementById("tip5"); guidetips[5] = document.getElementById("tip6"); guidetips[6] = document.getElementById("tip7"); startG.onclick = function(){ guideModal.style.display = "none"; controls.style.display = "block"; runGuideTips(); } function runGuideTips(){ guidetips[0].style.opacity="100"; for(i=0;i<guidetips.length;i++){ if(i === 0){ continue; } setTimeout(toggleTip(i), 3000); } } function toggleTip(i){ return function(){guidetips[i-1].style.opacity="0";guidetips[i+1].style.opacity="100";}; } When the user clicks the button to begin, I have the first tip start out by showing immediately. For that reason, I skip the first iteration. Then, each iteration after I want the prior tip to disappear and the current tip to appear. function toggleTip() was added when I read somewhere that by the time the timeout runs, the for loop is already complete. Their solution was to send the parameter in a function. It does work a little bit better than it was before. What it is doing right now is the first tip shows, then 3 seconds later it disappears and the last tip appears. I get an error in my Console that states: Unable to get property ' style' of undefined or null reference : referring to the function in toggleTip(). The expected result was to go through all 7 guidetips. At the end of the day, I am not certain if I am using the best method to accomplish the end goal that I described. I tried to Google this type of thing because I know I've seen it done before. But I wasn't able to find anything specific on it. So any input or suggestions would be appreciated. :)
  6. Spunky

    CSS Nav li hover fill

    The issue I am having is with my menu bar. I have recreated it in JS Fiddle. Notice that when you hover over any of the drop-down menu list items (any that are short words or not on 2 lines), the hover color does not spread to the right edge, and I am unable to figure out why. Could somebody take a look at let me know if they have any ideas?
  7. Spunky

    Using multiple child selectors

    Real simple here: Why does this work.. tr.retired td:not(:nth-child(2)){ background-color:purple; } And this works... tr.retired td:not(:nth-child(3)){ background-color:purple; } But this doesn't work? tr.retired td:not(:nth-child(2)),tr.retired td:not(:nth-child(3)){ background-color:purple; } Fiddle: https://jsfiddle.net/m6z1suyb/ Thanks!
  8. Spunky

    Using AngularJS/PHP, getting SQL error

    I prefer MySQLi so I will stick with that, thanks. Easier for me to comprehend as I am not a full fledged programmer. I know all about PDO being more versatile. Sure, ofcourse, my bad, I forget that I can easily run the PHP pages alone without the AJAX triggering it. So, the database connection is working. I ran retrieveData.php by itself and the echo $outp is outputting the data from my database as expected, into a JSON object. The issue now seems to lie solely with the AngularJS now so I'll end this topic as is and move onto a different forum area after I have played with this some more. Thanks for all of your helps. I am glad I finally have a working MySQLi connection to use here,for future projects, and to update older projects. You should test your PHP without AJAX first, or at least check the developer console to see exactly what's being returned in the AJAX request.
  9. Spunky

    Using AngularJS/PHP, getting SQL error

    They do, says string(#) "content" for each one. Plus the error is showing twice in the same alert box, not sure if that means anything or helps any. How, from my above code, could the $password be empty anyway??? Just to cover my bases from pointing fingers I have also tried: <?php $servername = "localhost"; $username = "username_user"; $password = "password"; $dbname = "username_TableName"; var_dump($servername, $username, $password, $dbname); $db_con = new mysqli('localhost','username_user','password','username_TableName'); if($db_con->connect_error){ die("Connection failed: " . $db_con->connect_error); } ?> (also I realize that where I have TableName is actually database name, I accidentally misinterpreted it as TableName, just don't want to correct it now for consistency) I did just notice, however, that data that I am entering to that the PHP is entering into the database with that connection is actually successfully being added. Hmm... thoughts? Also, I should point out that I am actually connecting to the database as soon as my page loads, before I try to enter data via my form which is actually where I am receiving my error. But I am not getting an SQL error when the page loads, just an AngularJS error which is what I am using with AJAX to communicate. here is the PHP that runs from the start: <?php header("Access-Control-Allow-Origin: *"); header("Content-Type: application/json; charset=UTF-8"); require 'databaseConnect.php'; $query='SELECT * FROM TaskTracker'; $db_con->query($query); $outp = ""; $result = $db_con->query($query); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { if($outp != ""){$outp .= ",";} $outp .= '{"desc":"' . $row["DESCRIPTION"] . '",'; $outp .= '"id":"' . $row["ID"] . '",'; $outp .= '"status":"' . $row["STATUS"] . '",'; $outp .= '"reminder":"' . $row["REMINDER"] . '",'; $outp .= '"todayDate":"' . $row["DATESTAMP"] . '"}'; } $outp='{"tasks":['.$outp.']}'; } $result->free(); $db_con->close(); echo($outp); ?> The error I am getting is: angular.js:13920 SyntaxError: Unexpected token s in JSON at position 0 Why it is suddenly having an issue with my JSON I do not know. I removed the headers though and that error went away. No error, but data is no longer being fetched from the database to my html page. Here's the AngularJS: $http.get("retrieveData.php").then(function(response){ $scope.tasks = response.data.tasks; }) I've done what I can to convert my code to MySQLi, but I may be missing certain things.
  10. Spunky

    Using AngularJS/PHP, getting SQL error

    http://stackoverflow.com/questions/30363045/running-php5-access-denied-to-mysqli-connection-but-success-for-mysql Can't say I haven't tried. Maybe you guys would like to take a crack at it then? Because they couldn't help. So let's stay focused on the important part: <?php $servername = "localhost"; $username = "username_user"; $password = "password"; $dbname = "username_TableName"; $db_con = new mysqli($servername,$username,$password,$dbname); if($db_con->connect_error){ die("Connection failed: " . $db_con->connect_error); } ?> The server specific information matches up exactly. All I did was convert it to MySQLi. The error I get: www.mysite.com says: Access denied for user 'username'@localhost (using password: NO) (yes, there is a strangely large gap between the top text and bottom which is right above the OK button.) Any help?
  11. Spunky

    Using AngularJS/PHP, getting SQL error

    I am unable to connect to my server when I convert the code to MySQLi and I have not been able to figure out why. But I am not too concerned, I only work on small, personal projects. I already discovered what happens when I add an apostrophe to the string which is it doesn't add the item to the database. So I am unsure how that is what is happening here. The code works, it's just now that I am trying to receive $returnData I am getting the error, however the data is still being added to the database. My code was created with the help of w3schools, maybe about 10 years ago, yes. But no need to insult the code, it works, let's focus on the code that isn't working, please.
  12. So I am posting this issue in this part of the forum due to the SQL error that I am getting, so my best guess is there is an error in my SQL. Basically, what I am doing is using angularjs's $https to communicate with a PHP file. Here is that code: $http.post('enterTask.php', task).then( function(response){ alert(response.data); $scope.tasks.push(task); } ); So, I am sending some data which works fine. Where I am getting the error was when I decided I want to receive back data as well and I am using the alert to test the response. Here is the PHP code: <?php $description = $data->desc; $reminder = $data->reminder; $todayDate = $data->todayDate; $status = $data->status; require 'databaseConnect.php'; $query="INSERT INTO TaskTracker (DATESTAMP,STATUS,DESCRIPTION,REMINDER) VALUES ('$todayDate','$status','$description','$reminder')"; mysql_query($query) or die(mysql_error()); $query="SELECT ID FROM TaskTracker WHERE DESCRIPTION = $description"; $result = @mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)){ $returnData = $row["ID"]; } } mysql_close($db_link); echo $returnData; ?> Again, most of this code works just fine, the issue came in when I added everything from the 2nd query and beyond. Here is the error that I am getting when the AJAX runs: You have an error in your SQL syntax: check the manual that corresponds to your MySQL server version for the right syntax to use near 'a 7th test for good luck' at line 1 Part of the data I am sending is here is a 7th test for good luck. And this is stored in $description. Every time this error pops up, it cuts off the first part of it, which I imagine is some clue as to where the error is in the SQL. Any idea? PS: Sorry the PHP code is sloppy, for some reason it appears blank when I post with it in the code box..
  13. Spunky

    Handle form with AJAX & PHP

    2 typos.. this is what I get for staying up till midnight trying to get this to work... ok so this is what I am getting sent to my email now: Name: [object HTMLParagraphElement]Email: Comment: [object HTMLTextAreaElement] I am not sure why email is still not showing anything. Also I realized I was supposed to add .value to the ends like this: var fn = document.getElementById('fname').value; var ln = document.getElementById('lname').value; var e = document.getElementById('email').value; var p = document.getElementById('phone').value; var m = document.getElementById('message').value; But that didn't do anything. Still, the #1 issue is that the first time I press submit it just reopens the modal the form is in and then it is the second time that it submits. I can try to take it out of the modal and see if that changes anything but either way, I really need it inside the modal. --turns out getting rid of the form fixed this, no need for it I guess anyways since I am not using "onsubmit". EDIT: I am trying to troubleshoot this. When I alert any one of the variables (fn, ln, e, etc) it is undefined and I am not sure why. My JS is located at the bottom of the page before the end body tag so I don't think I need a document ready function but I have tried implementing one which just seems to make it worse. EDIT: Alright this is starting to tick me off.. this is the SIMPLEST JavaScript that I am unable to get to work, I even tried to put it on JsFiddle for a more clear picture and even THAT I can't get to work...https://jsfiddle.net/k1g9dq7w/ -- but anyway this is the code I am currently trying to debug.. simple.. basic.. maybe at this point I should go to the JS forum with this I don't know. ^^^ Ok it seems that if the input is not in a modal, the JS will retrieve the value no problem. I know this is a JS question now, so I am just going to take this to the JS Forums, instead, I have tested this manually by doing: var userdata = "firstname=MyName&lastname=MyLastName&email=email@email.com&phone=123&message=message"; and now this works. So, the code works. I thank you. I will have to figure out my other issue.
  14. Spunky

    Handle form with AJAX & PHP

    HTML: <form id="contact_form"> <p id="fname" class="form_items"> <input type="text" name="fname" id="fname" placeholder="First Name" required /> </p> <p id="lname" class="form_items"> <input type="text" name="lname" id="lname" placeholder="Last Name" required /> </p> <p id="email" class="form_items"> <input type="email" name="email" id="email" placeholder="Email" required /> </p> <p id="phone" class="form_items"> <input type="tel" name="phone" id="phone" placeholder="Telephone" /> </p> <p id="comments" class="form_items"> <textarea rows="4" cols="50" name="message" placeholder="Comments" id="message"></textarea> </p> <p> <button class="submit" type="submit" onclick="submitForm();">Submit</button> </p> <span id="status"></span> </form> JS: function submitForm(){ var xmlhttp = new XMLHttpRequest(); var fn = document.getElementById('fname'); var ln = document.getElementById('lname'); var e = document.getElementById('email'); var p = document.getElementById('phone'); var m = document.getElementById('message'); var userdata = "firstname="+fn+"&lastname="+ln+"$email="+e+"&phone="+p+"&message="+m; xmlhttp.open("POST","submit_form.php",true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ retrieve = xmlhttp.responseText; document.getElementById("status").innerHTML = retrieve; } } xmlhttp.send(userdata); document.getElementById("status").innerHTML = "processing..."; } PHP(submit_form.php): $ToEmail = 'email@email.com'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["first"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["message"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); So now what is happening is that the first time I hit the submit button, my modal closes and reopens, I see "processing..." appear briefly as this happens, but nothing gets sent to email and when the modal reappears there is no status text. When I fill the form out again however, "processing..." shows up briefly then disappears and I have an email. However, this is the contents of the email: Name: Email: Comment: [object HTMLTextAreaElement] There is no updated status text at this time. I assume the modal closing and reopening may be a modal specific issue? Even so, anyone have any ideas why this is happening? But I am sure the modal issue isn't hindering the PHP issue. I am unsure why the data is still not sending properly, or why it is showing what it is for the Comments. Any ideas? Is there suppose to be status text at this time?
  15. Spunky

    Handle form with AJAX & PHP

    I am trying to use AJAX to run some PHP code and I have it working but I am not sure how to send my form information to the PHP code. I have used this PHP code before with a form but that's used something like "onsubmit="thankyou.php" where the PHP page was just like a landing page that the user reviews the information that they sent. Now that I am using AJAX, this is what I have so far: HTML: <form id="contact_form" onsubmit="submitForm();"> <p id="fname" class="form_items"> <input type="text" name="fname" id="fname" placeholder="First Name" required /> </p> <p id="lname" class="form_items"> <input type="text" name="lname" id="lname" placeholder="Last Name" required /> </p> <p id="email" class="form_items"> <input type="email" name="email" id="email" placeholder="Email" required /> </p> <p id="phone" class="form_items"> <input type="tel" name="phone" id="phone" placeholder="Telephone" /> </p> <p id="comments" class="form_items"> <textarea rows="4" cols="50" placeholder="Comments"></textarea> </p> <p> <button class="submit" type="submit">Submit</button> </p> </form> JS: function submitForm(){ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ retrieve = xmlhttp.responseText; } } xmlhttp.open("POST","submit_form.php"); xmlhttp.send(); } PHP(submit_form.php): $ToEmail = 'email@email.com'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["firstName"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["message"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); I am receiving an email, but everything is blank. I am not seeing any errors in my console or anything. Nothing happens when the form is submitted otherwise. A little background on what I am trying accomplish: I have a contact form appearing in a homemade modal (not bootstrap) where the user can fill it out and then submit without being sent to a landing page.
×