Source Code for Our String-Formatting Script : String : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » String »

 

Source Code for Our String-Formatting Script




<html>
<head>
  <title>String Object Formatting</title>
  <script language="JavaScript1.1" type="text/javascript">
  <!--
    function showWindow() {
   
      var txt = document.form1.stringField.value;
      var clr = "";
      var sze = "";
   
      if (document.form1.bigBox.checkedtxt = txt.big();
      if (document.form1.blinkBox.checkedtxt = txt.blink();
      if (document.form1.boldBox.checkedtxt = txt.bold();
      if (document.form1.fixedBox.checkedtxt = txt.fixed();
      if (document.form1.italicsBox.checkedtxt = txt.italics();
      if (document.form1.smallBox.checkedtxt = txt.small();
      if (document.form1.strikeBox.checkedtxt = txt.strike();
      if (document.form1.subBox.checkedtxt = txt.sub();
      if (document.form1.supBox.checkedtxt = txt.sup();
   
      clr = document.form1.colorList.options[document.form1.colorList.options.selectedIndex].text;
      txt = txt.fontcolor(clr);
      sze = document.form1.sizeList.options[document.form1.sizeList.options.selectedIndex].text;
      txt = txt.fontsize(sze);

      objWindow = window.open("""","width=600,height=300");
      objWindow.document.write(txt);
      
      objWindow.document.close();
  }
  //-->
  </script>
</head>
<body>
  <h1>
    String Object Formatting
  </h1>
  <hr>
  <form method="POST" name="form1">
    <p>
      <strong>
        String:
      </strong>
      <input type=text size=40 maxlength=256 name="stringField">
    </p>
    <p>
      <strong>
        Style:
      </strong>
      <input type=checkbox name="bigBox" value="ON">
      Big
      <input type=checkbox name="blinkBox" value="ON">
      Blink
      <input type=checkbox name="boldBox" value="ON">
      Bold
      <input type=checkbox name="fixedBox" value="ON">
      Fixed
      <input type=checkbox name="italicsBox" value="ON">
      Italics
      <input type=checkbox name="smallBox" value="ON">
      Small
      <input type=checkbox name="strikeBox" value="ON">
      Strike
      <input type=checkbox name="subBox" value="ON">
      Sub
      <input type=checkbox name="supBox" value="ON">      Sup
    </p>
    <p>
      <strong>
        Font:
      </strong>
      Color:
      <select name="colorList" size=1>
        <option selected>black</option>
        <option>green</option>
        <option>red</option>
        <option>yellow</option>
        <option>white</option>
      </select>
      Size:
      <select name="sizeList" size=1>
        <option selected>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
      </select>
    </p>
    <input type="button" name="Show" value="Show" onClick="showWindow()">
  </form>
</body>
</html>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» String