Jump to content

Doesn't Work in FF OR Opera


Joseph Witchard

Recommended Posts

JavaScript:

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:

<!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. Could someone explain to me why this isn't working? The JavaScript doesn't do anything when you press the bold and italic buttons, and it does nothing when you submit the form with the wrong data. NOTE: If the bold and italic JavaScript functions show empty quotes, that's because BBCode goes there.

Link to comment
https://forums.phpfreaks.com/topic/134570-doesnt-work-in-ff-or-opera/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.