Source Code for Our String-Formatting Script : String « Language Basics « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Event
7. Event onMethod
8. Form Control
9. GUI Components
10. HTML
11. Javascript Collections
12. Javascript Objects
13. Language Basics
14. Node Operation
15. Object Oriented
16. Page Components
17. Security
18. Style Layout
19. Table
20. Utilities
21. Window Browser
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
JavaScript DHTML » 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>

           
       
Related examples in the same category
1. Demo all String methods
2. String utility: word count, replace and capitalize
3. Strip Commas
4. Text Range Search and Replace (IE only)
5. Counting the Words in a Text String
6. Reversing a String
7. Trimming a String Using Regular Expressions
8. String encode and decode
9. Capitalizing the First Letter in Each Word of a String
10. Playing with Strings
11.  Using the String Object's Link Method
12. Using a for Loop to Reverse a String
13.  Concatenate JavaScript String
14. String length: number of characters in a string.
15. String fontcolor(): a string in a specified color
16. String indexOf(): string position
17. String Validation
18. Using Quotes within Strings
19. Using the String Object
20. String toUpperCase
21. Lab for string.replace() and string.search()
22. Slicing a String
23. A String Object Prototype
24. Creating a Custom toString() Method
25. Reading a Portion of a String
26. Source Code for a Sample Page That Formats a String Object with the 'a' Tag
27. Adding a replace() Method to the String Object
28. Creating a Function That Will Search and Replace in Strings
29.  Using the indexOf() Method to Find All Occurrences of the Letter e in a Sentence
30. Methods and Properties of the String Object
31. String match(): returns the text if found
32. String substr() and substring(): returns a specified part of a string
33. String toLowerCase() and toUpperCase(): converts a string to lowercase and uppercase
34. Converting Strings to Upper Case
35. String encoder
w__ww_.__j_av___a_2___s_.___c_om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.