JavaScript:
HTML Form:Code:function goBold() { var goBoldButton = prompt("Please enter the text that is to be bold", ""); var boldText = "" + goBoldButton + ""; document.newsForm.newsBody.value += boldText; } function goItalic() { var goItalicButton = prompt("Please enter the text that is to be italic", ""); var italicText = "" + goItalicButton + ""; document.newsForm.newsBody.value += italicText; } function errorCheck() { var body = document.newsForm.newsBody.value; var title = document.newsForm.newsTitle.value; // check to see that the information is valid if (body == "" || body == "NULL") { alert("Please enter some news!"); return false; } else if (title == "" || title == "NULL") { alert("Please enter a news title!"); return false; } else { return true; }
I swear JavaScript hates me. Can someone explain to me why this isn't working? Nothing happens when I click the BOLD or ITALIC buttons, and it doesn't work right when I submit the form with the wrong data, eitherHTML Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Rebirth Administration News Center</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="cache-control" content="no-cache"> <link href="/css/general2.css" rel="stylesheet" type="text/css"> <script language="javascript" type="text/javascript" src="/javascripts/aaNews.js"></script> </head> <body> <div align="center" style="text-align: center;"> <h2>News Form</h2> <form id="newsForm" name="newsForm" method="post" action="https://uhrebirth.com/staff/lets_go.php" onSubmit="return errorCheck();"> <label for="newsTitle">Title:</label> <input type="text" id="newsTitle" name="newsTitle" size="30"> <br> <br> <label for="newsType">Category:</label> <select id="newsType" name="newsType"> <!-- SERVER SIDE CODE GOES HERE --> </select> <br> <br> <label for="newsBody">Body:</label> <br> <textarea id="newsBody" name="newsBody" style="width: 500px; height: 200px; overflow: auto;"></textarea> <br> <br> <input type="button" value="BOLD" onClick="goBold();"> <input type="button" value="ITALIC" onClick="goItalic();"> <br> <br> <input type="submit" id="submit" name="submit" value="Submit News"> <input type="reset" value="Reset"> </form> </div> </body> </html>
P.S. The reason it's showing empty quotes in the bold and italic functions is because BBCode goes there.



Reply With Quote
Thanks for the help

Bookmarks