Jump to content

Wolverine68

Members
  • Posts

    83
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Wolverine68's Achievements

Member

Member (2/5)

0

Reputation

  1. Trying to create a simple Event Listener such that was a key is press the element of the id is highlighted. I'm using IE, so I used "attachEvent" instead of addEventListener. Not getting any response when any of the keys are pressed. http://goken68.brinkster.net/EventListeners.html <html> <body> <head> <script type="text/javascript" language="javascript"> var ev = document.getElementById("north") ev.attachEvent('onkeydown',highlight,false); ev.attachEvent('onkeyup',highlight,false); </script> </head> <div id="teams"> <h1>NFL Teams</h1> <h2 id="north">NFC North</h2> <p>Chicago Bears</p> <p>Green Bay Packers</p> <p>Minnesota Vikings</p> <p>Detroit Lions</p> <h2>NFC South</h2> <p>New Orleans Saints</p> <p>Atlanta Falcons</p> <p>Carolina Panthers</p> <p>Tampa Bay Buccannears</p> <h2>NFC East</h2> <p>Dallas Cowboys</p> <p>Washington Redskins</p> <p>Philadelphia Eagles</p> <p>NY Giants</p> <h2>NFC West</h2> <p>San Francisco 49ers</p> <p>Arizona Cardinals</p> <p>Seattle Seahawks</p> <p>St.Louis Rams</p> </div>
  2. I was using Internet Explorer 8. When I tried it using Mozilla Firefox, it worked. Any thoughts on why it wouldn't work in Internet Explorer?
  3. Trying to familiarize myself with the preventDefault() event. Created a simple page so that when clicking on a url link, it displays a pop up box instead of, by default, opening up the website. When clicking on the link, it still opens the website. I tried using onmouseover instead of onClick and got errors: http://goken68.brinkster.net/PreventDefault.html Code: <html> <body> <head> <script type="text/javascript" language="javascript"> function urlClick(evt) { evt.preventDefault(); alert("You do not have access rights to that website!"); } </script> </head> <p>Click on the link below to see preventDefault() in action:</p> <br /> <br /> <a href="http://www.irs.gov" onClick="urlClick(event)">Go to Website</a> </body> </html>
  4. Just trying to right a simple script that will search for and display the child nodes and parent node when the applicable button is clicked. When clicking on "Show Child Nodes", nothing happens. When clicking on "Show Parent Node", the alert box just displays "null". http://goken68.brinkster.net/ChildandParentNodes.html <html> <body> <head> <script type="text/javascript" language="javascript"> function getchildNodes() { var content = document.getElementById("teams");//find the child Nodes of this element for (var i = 0; i < content.length; i++) { alert(content[i].childNodes.nodeValue);//display all the child nodes for the element, "teams".12:15 PM 2/8/2012 } } function getParentNode() { var node = document.getElementById("north");//find parent node of this element. alert(node.parentNode.nodeValue);//Display the parent node for element, "north". } </script> </head> <div id="teams"> <h1>NFL Teams</h1> <h2 id="north">NFC North</h2> <p>Chicago Bears</p> <p>Green Bay Packers</p> <p>Minnesota Vikings</p> <p>Detroit Lions</p> <h2>NFC South</h2> <p>New Orleans Saints</p> <p>Atlanta Falcons</p> <p>Carolina Panthers</p> <p>Tampa Bay Buccannears</p> <h2>NFC East</h2> <p>Dallas Cowboys</p> <p>Washington Redskins</p> <p>Philadelphia Eagles</p> <p>NY Giants</p> <h2>NFC West</h2> <p>San Francisco 49ers</p> <p>Arizona Cardinals</p> <p>Seattle Seahawks</p> <p>St.Louis Rams</p> </div> <input type="button" value="Show Child Nodes" onclick="getchildNodes()"> <br /> <br /> <input type="button" value="Show Parent Node" onclick="getParentNode()"> </body> </html>
  5. Trying to create a simple document that gets the parentNode then applies a background color. My getElementByTagName is "p" so the parentNode would be the <body>. The background color should then be applied to the entire document, right? I'm getting an "object expected" error. http://goken68.brinkster.net/ParentNode.html //purpose is to use parent node and change the background color <html> <body> <head> <script type="text/javascript" language="javascript"> function changeIt() { var node; node = document.getElementsByTagName("p").parentNode; node.style.background-color = '#0033dd'; } </script> </head> <div id="teams"> <h1>NFL Teams</h1> <h2>NFC North</h2> <p>Chicago Bears</p> <p>Green Bay Packers</p> <p>Minnesota Vikings</p> <p>Detroit Lions</p> <h2>NFC South</h2> <p>New Orleans Saints</p> <p>Atlanta Falcons</p> <p>Carolina Panthers</p> <p>Tampa Bay Buccannears</p> <h2>NFC East</h2> <p>Dallas Cowboys</p> <p>Washington Redskins</p> <p>Philadelphia Eagles</p> <p>NY Giants</p> <h2>NFC West</h2> <p>San Francisco 49ers</p> <p>Arizona Cardinals</p> <p>Seattle Seahawks</p> <p>St.Louis Rams</p> </div> <input type="button" value="change background color" onClick="changeIt()"> </body> </html>
  6. Made some changes. Now, the alert box only displays "undefined". http://goken68.brinkster.net/GetElementsByTag2.html <html> <body> <head> <script type="text/javascript" language="javascript"> function getNodes() { var content = document.getElementsByTagName('*');//using asterick as a wild card so that all nodes will be searched. for (var i = 0; i < content.length; i++) { alert(content[i].childNodes.innerHTML); } } </script> </head> <div id="teams"> <h1>NFL Teams</h1> <h2>NFC North</h2> <p>Chicago Bears</p> <p>Green Bay Packers</p> <p>Minnesota Vikings</p> <p>Detroit Lions</p> <h2>NFC South</h2> <p>New Orleans Saints</p> <p>Atlanta Falcons</p> <p>Carolina Panthers</p> <p>Tampa Bay Buccannears</p> <h2>NFC East</h2> <p>Dallas Cowboys</p> <p>Washington Redskins</p> <p>Philadelphia Eagles</p> <p>NY Giants</p> <h2>NFC West</h2> <p>San Francisco 49ers</p> <p>Arizona Cardinals</p> <p>Seattle Seahawks</p> <p>St.Louis Rams</p> </div> <input type="button" value="Show Nodes" onclick="getNodes()"> </body> </html>
  7. Trying to run a script that will display the name of every node in an HTML document. The URL to my page is below. When clicking on the "Show nodes" button, it gives "object expected" error for line 50 http://goken68.brinkster.net/GetElementsByTag.html <html> <body> <head> <script type="text/javascript" language="javascript"> function getNodes() { var content = document.getElementsByTagName(*); for (var i = 0; i < content.length; i++) { document.write(content[i].nodeName.innerHTML); } } </script> </head> <h1>NFL Teams</h1> <h2>NFC North</h2> <p>Chicago Bears</p> <p>Green Bay Packers</p> <p>Minnesota Vikings</p> <p>Detroit Lions</p> <h2>NFC South</h2> <p>New Orleans Saints</p> <p>Atlanta Falcons</p> <p>Carolina Panthers</p> <p>Tampa Bay Buccannears</p> <h2>NFC East</h2> <p>Dallas Cowboys</p> <p>Washington Redskins</p> <p>Philadelphia Eagles</p> <p>NY Giants</p> <h2>NFC West</h2> <p>San Francisco 49ers</p> <p>Arizona Cardinals</p> <p>Seattle Seahawks</p> <p>St.Louis Rams</p> <input type="button" value="Show Nodes" onclick="getNodes()"> </body> </html>
  8. Can't get a simple request form with mail() function to work. When clicking on the Submit button, it goes to the feedback.php file but just shows a blank page. It doesn't display the "Thank you, your request has been submitted" message along with the date and time which I included in the coding. HTML form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Request Form</title> </head> <body background="#EEEEEE"> <h3 align="center">Request to Add to E-Mail List</h3> <div> <form action="feedback8.php" method="post"> <p><font color="blue">If you'd like to be added to the e-mail list, simply fill in your name and e-mail address, then click "Submit"</font></p> <hr width="100%"> <p>Name:&nbsp&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="name"></p> <p>E-mail:&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="email"></p> <br><br> <input type="submit" name="submit" value="Submit"><br><br> <hr width="100%"> </div> </body> </html> PHP file: <?php $formBody="Name:$name\nEmail:$email"; $headers = "From:$email"; if ($submit) { mail("me@yahoo.com", "Add to E-mail List Request", $formBody, $headers); } if ($submit) { print "Thank you. Your request has been submitted <br /> <br />"; print "Current date and time :"; print date("F j, Y g:i A T"); } ?>
  9. I just installed PHP. To confirm it's been installed I created the following test file as index.php: <html> <head> <title>My First PHP Page from my Local Server</title> </head> <body> <?php print "<h1>Hello World</h1>"?> </body> </html> I then saved the file to the root. But, when I try to display the web page, http://localhost/index.php I get the error, "404 - File Not Found". I saved it to "C:\ ". That is the "root", right?
  10. My webhost is Ripway, http://www.ripway.com I have a free account but it says PHP scripting is supported. Got any other recommendations of web hosts that offer a free account with PHP support?
  11. I created a form using the mail() function. Upon submission, it's just suppose to email the information entered. Instead, I get the error "HTTP Error 405 - The HTTP verb used to access this page is not allowed." <body> <?php $recipient = "me@yahoo.com"; $subject = "Registration Submission"; $body = "<h2>Registration Information:</h2>"; if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['question'])) { $body .= "\r\nName: " . $_POST['name']; $body .= "\r\nEmail: " . $_POST['email']; $body .= "\r\nQuestion: " . $_POST['question']; } if (mail($recipient, $subject, $body)) { print("Email successfully sent!"); } else { print("The email could not be sent."); } ?> <form method="POST" action=""> <h2 align="center">Sending Email</h2> <br /> <div> <p>Enter your name and email address, a question, and click "Submit":</p> <br /> <p>Name:<input type="text" name="name" size="20"></p> <p>Email:<input type="text" name="email" size="20"></p> <p>Question:<input type="text" name="question" size="20"></p> </div> <br /> <div> <input type="submit" name="submit" value="Submit" /> </div> <br /> <div> <input type="reset" name="Reset" value="Start Over" /> </div> </form> </body> </html>
  12. Just tried to create a simple form where the user enters a message to display. When submitted, it is to save the message to a text file. When clicking on "Message to Display" it gives the error "Fatal error: Call to undefined function: file_put_contents() in \\192.168.0.16\webfiles\files\2011-5\3627559\setmessage.php on line 16" <?php if($_SERVER['REQUEST_METHOD'] != 'POST') { ?> <form method="POST" action="setmessage.php" name="setmessage"> <p>Message to Display:<Input type="text" name="message" size="50"></p> <p><input type="submit" value="Submit" name="submit"></p> </form> <?php } else { //Writes the contents of the message to a file file_put_contents('message.txt', $_POST['message']); } ?> I also tried print file_put_contents('message.txt', $_POST['message']); and echo file_put_contents('message.txt', $_POST['message']); Still get the same error
  13. Just trying to create a simple form that will let you enter a message that will get written to a text file. Code for SetMessage.php: <?php if($_SERVER['REQUEST_METHOD'] != 'POST') { ?> <form method="POST" action="setmessage.php" name="setmessage"> <p>Message to Display:<Input type="text" name="message" size="50"></p> <p><input type="submit" value="Submit" name="submit"></p> </form> <?php } else { //Writes the contents of the message to a file echo file_put_contents('message.txt', $_POST['message']); } ?> When submitting, I get the error "Call to undefined function: file_put_contents() on line 16"
×
×
  • 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.