www.webdeveloper.com
Results 1 to 3 of 3

Thread: Script Not Working in FF OR Opera

  1. #1
    Join Date
    Dec 2007
    Location
    Mississippi
    Posts
    1,063

    Script Not Working in FF OR Opera

    JavaScript:
    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;
              
            }
    HTML Form:
    HTML 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>
    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, either

    P.S. The reason it's showing empty quotes in the bold and italic functions is because BBCode goes there.

  2. #2
    Join Date
    Oct 2008
    Posts
    349
    If you pasted javascript exactly, then the problem is that you forgot to close the "}" for errorCheck function.

  3. #3
    Join Date
    Dec 2007
    Location
    Mississippi
    Posts
    1,063
    I feel very stupid right now Thanks for the help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles