How to create a class using java script..

Hi all,
Iam new to java script and I tried out the following program but its not working..I basically created a class just like a java prog' but Iam not getting any output or error.Iam attaching the code below.
If I created one function inside the script and create one object its working fine but what should I do when I have a lot of function??so I created a class and put all the function and created an object but its not working..
Do let me know what changes should I do..Iam attaching the code which I had written. or give me an example of how to create a class with couple of functions using JAVASCRIPT
Thanks
Avis_su
<html>
<head><title>JSP Page</title></head>
<body>
<SCRIPT language = "JavaScript">
<!--
//Created classes
class book
var title: String;
var author:String;
function author()
doucument.write("Author is " +this.author);
function tile()
doucument.write("Title is " +this.title);
function printall()
var counter = 0;
function author();
function title();
var chapters = Array[String];
for(chapter in this chapters)
counter++;
document.write("Chapter" counter" :"+this.chapters[chapter]+"<br>");
var thisbook = new book()
thisbook.author = "Sivagami";
thisbook.title = "MS in CS giude";
thisbook.chapters = new Array[10];
thisbook[0] = "Prepare to Excell in all ";
thisbook[1] = "Learn to be happy";
thisbook[2] = "Learn to be healthy mentally emotionally physically";
thisbook[3] = "Siva and Subbu along with kidssssss will be successful in future";
thisbook.printall();
//-->
</script>
</body>
</html>

Run this program to get your answer:
public class AnswerToYourPost {
public static void main(String args[]) {
System.out.println("TRUE/FALSE: This question
ion belongs on a Java forum.\n"
+ "ANSWER: " + ("Javascript" == "Java"));
}Since when do we compare objects for equality using operator == ?

Similar Messages

  • How to run .jar on linux & how to create .jar file using java?

    hi, may i know how to run .jar on linux & how to create .jar file using java? Can u provide the steps on doing it.
    thanks in advance.

    Look at the manual page for jar:
    # man jar
    Also you can run them by doing:
    # java -jar Prog.jar

  • How to create sub domain using java ?

    how to create sub domain using java ?
    for example:
    name1.domainname.com
    name2.domainname.com
    is it possibe ?

    You don't do that using Java.
    Consult the documentation of the application server in question how to configure it. If you're using for example Tomcat 6.0, then you should be consulting this document: [http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html].

  • How we close Views without using Java Script

    Hi All,
    can you please suggest me how i close view with out using java script.
    if possible please reply with code.
    Thanks
    Siva

    Hi Siva,
    You can do this either by hiding your window or by closing the window. Following is the sample code to do that
    IWDWindowInfo windowInfo = null;
    IWDWindow window =null;
    windowInfo = (IWDWindowInfo)  wdComponentAPI.getComponentInfo).findInWindows("<<WindowName>>");
    if(windowInfo!=null)
    window = wdComponentAPI.getWindowManager().createWindow(windowInfo,true);
    window.hide();
    Try with this code, might be useful for your scenario.
    Thanks,
    Sandeep

  • How to create a TOOLBOX using Java  - a real CHALLENGE for U

    Hello,
    I want to create a Toolbox using Java which will contain different components of my interest.I should be able to select one component and paste it in a frame also be able set the property of individual component after placing in the frame,just like VB toolbox.
    Can anybody suggest with code samples??
    Regards,
    Suraj.

    You are essentially asking how to write an IDE (Integrated Development Environment). This is a big question. You might start by looking at existing IDE's (JBuilder, Forte...) and see how they do it. If you want source, there is probably an open source IDE you can lift most of your code from.

  • How to generate Serial numbers using JAVA SCRIPT

    how to generate serial numbers(incrementing by 1) using JAVA SCRIPT
    thanking you,
    pola pradeep

    i am afraid that whether ur looking for this. bcoz its a simple for loop
    <script language="JavaScript">
    //count = limit value for u
    for(i=0;i<count;++i){
         alert(i);
    </script>
    or if ur looking for something else, pls mention ur requrment precisely
    aleena

  • How to create sql database using java frame or appelet?

    hi ! i am working on database project i want to create a database using java frame or applet where it asks user to select the location for database to be created , after user have specified the path then the programs creates the database, again i want that database to be read and write by another frame or applet but as user select the path how do i make the connectivity. i just have basic knowledge on java. please give me idea how can i process further.
    thanks a lot

    While duffymo is correct in regard to most major database products, it's my understanding (warning! wild-ass guess coming) that the Hypersonic DB is more "application-centric" and the dynamic creation of databases is part of its design. It's pure Java database software, and therefore is not appropriate for all database projects, in particular those that require extremely high-performance.
    See http://hsqldb.org/
    I've not used it yet (but soon though), and I can't really advise anyone about it.
    However, I'm wondering if you phrased you question in a way that is confusing us. To most of us in casual conversation, a "database" is both (1) a large organized collection of data and (2) the software that is used to organize and access it. However, the phrase "create a database" usually means creating a (1) database (a collection of data) using an already created (2) database software, such as Oracle, MySQL, DB2, HSQDB, etc., etc. If you'r question is, how do a create some new database software using Java, the answer is that this is a very very big and hard thing to do for the general case and probably not something you want to be doing.

  • How to create a Folder using java.

    Hi All,
    I have a doubt. I want to create a folder using java.
    Inputs are the destination where the folder should be created and the name of the folder. Plz help me in this regard.
    thanks and regards,
    Vincent .R.

    check out javadoc for java.io
    File reldir=new File("NewDir");//relatively where your program runs
    reldir.mkdir();
    File absdir=new File("C:/NewDir");//absolute path
    reldir.mkdir();
    File newdir=new File(absdir,"SubDir");//defines another dir under absdir
    newdir.mkdir();
    Gil

  • How to disable a button using Java Script in Apex

    Hi All,
    I was trying to disable a button when the value of a select list item in the same page is equal to zero. Following are the steps which I did.
    1) Created a new button template as <table class="t9StandardButton" id="#BUTTON_ID#" cellspacing="0" cellpadding="0" border="0" summary="">
    2) Changed the existing button template to the newly created button template.
    3) Added onchange="javascript:fdisplay(this);" to form element value of select list
    4) Added the following java script in the page header
    <script type="text/javascript">
    function fdisplay(some) {
    if (some.value==0){
    html_GetElement ('#BUTTON_ID#').disabled = true;
    else
    html_GetElement ('#BUTTON_ID#').disabled = false;
    </script>
    But the script doesn't work. Is there anything I am missing here. Please advice.
    Thanks,
    Vikas

    Vikas:
    In the 'Button Attributes' field of the button enter 'id='thisButton'.
    Modify the button template to include the substitution string #BUTTON_ATTRIBUTES# . This should be put in the anchor tag in the template defintion.
    Modify your Javascript to reference the above id as
    html_GetElement ('thisButton').disabled = true;
    ....Varad

  • How to create a database using Java?

    Hi there..
    I'm a student who is currently studying IT and was asked to do a project based on database but create using Java.. since i'm a beginner..i was wondering whether is it possible to do that?
    and if it is possible.. can you kindly show me a sample of code on how to start the project...
    thank you
    yours sincerely,
    Shafini

    While duffymo is correct in regard to most major database products, it's my understanding (warning! wild-ass guess coming) that the Hypersonic DB is more "application-centric" and the dynamic creation of databases is part of its design. It's pure Java database software, and therefore is not appropriate for all database projects, in particular those that require extremely high-performance.
    See http://hsqldb.org/
    I've not used it yet (but soon though), and I can't really advise anyone about it.
    However, I'm wondering if you phrased you question in a way that is confusing us. To most of us in casual conversation, a "database" is both (1) a large organized collection of data and (2) the software that is used to organize and access it. However, the phrase "create a database" usually means creating a (1) database (a collection of data) using an already created (2) database software, such as Oracle, MySQL, DB2, HSQDB, etc., etc. If you'r question is, how do a create some new database software using Java, the answer is that this is a very very big and hard thing to do for the general case and probably not something you want to be doing.

  • How to create a LAN using java

    i want to create a LAN like environment using java [ maximum 4 clients] - how do i do this using socket programming .

    Create 4 independent network clients and this will work like four clients on different machines.

  • How to create tagged PDF using java iText

    Hi
    I want to create PDF for accessibility purpose using java and iText
    Please help.
    Thanks in advance

    i did this some yrs ago ..scratched and found some code for you. Have a look
    package com.oq.utility;
    import com.lowagie.text.Cell;
    import com.lowagie.text.Document;
    import com.lowagie.text.Element;
    import com.lowagie.text.Font;
    import com.lowagie.text.HeaderFooter;
    import com.lowagie.text.Image;
    import com.lowagie.text.PageSize;
    import com.lowagie.text.Phrase;
    import com.lowagie.text.Rectangle;
    import com.lowagie.text.Table;
    import com.lowagie.text.pdf.BaseFont;
    import com.lowagie.text.pdf.PdfWriter;
    import com.oq.model.Sale;
    import java.io.FileOutputStream;
    import java.util.ArrayList;
    import java.util.List;
    public class iTextExample
        public static void main (String[] args)
            iTextExample eg = new iTextExample();
            Sale sale = new Sale();
            sale.setOdrNumber("1");
            sale.setOdrDate("12-12-12");
            sale.setOdrCatCode("Örder");
            sale.setTotalInvValue("1234");
            sale.setRefNumber("in the line of fire");
            Sale sale1 = new Sale();
            sale1.setOdrNumber("1");
            sale1.setOdrDate("12-12-12");
            sale1.setOdrCatCode("Örder");
            sale1.setTotalInvValue("1234");
            sale1.setRefNumber("fire line");
            Sale sale2 = new Sale();
            sale2.setOdrNumber("1");
            sale2.setOdrDate("12-12-12");
            sale2.setOdrCatCode("Örder");
            sale2.setTotalInvValue("1234");
            sale2.setRefNumber("in the line of firel");
            List<Sale> list = new ArrayList<Sale>();
            list.add(sale);
            list.add(sale1);
            list.add(sale2);
            eg.printPDF(list);
        public void printPDF(List list) {
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);
            try
                // creation of the different writers
                PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("iTextExample.pdf"));
                // various fonts
                BaseFont bf_helv = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false);
                BaseFont bf_times = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", false);
                BaseFont bf_courier = BaseFont.createFont(BaseFont.COURIER, "Cp1252", false);
                BaseFont bf_symbol = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", false);
                // headers and footers must be added before the document is opened
                HeaderFooter footer = new HeaderFooter(
                            new Phrase("This is page: ", new Font(bf_courier)), true);
                footer.setBorder(Rectangle.NO_BORDER);
                footer.setAlignment(Element.ALIGN_CENTER);
                document.setFooter(footer);
                HeaderFooter header = new HeaderFooter(
                            new Phrase("This is a header without a page number", new Font(bf_symbol)), false);
                header.setAlignment(Element.ALIGN_CENTER);
                document.setHeader(header);
                document.open();
                Image img = Image.getInstance("arrow-ff.gif");
                img.setAlignment(Image.RIGHT | Image.TEXTWRAP);
                Table goodTable = new Table(2);     
                      Cell cell1 = new Cell(img);
                goodTable.addCell(cell1);
                document.add(goodTable);
                Cell c = new Cell("Header");
                c.setHeader(true);
                goodTable.addCell(c);
                Cell c1 = new Cell("Header1");
                c1.setHeader(true);
                goodTable.addCell(c1);
                Cell c2 = new Cell("Header2");
                c2.setHeader(true);
                goodTable.addCell(c2);
                goodTable.endHeaders();
                int j=0;
                          while (j< list.size())
                              Sale sale = (Sale)list.get(j);
                              c = new Cell(sale.getOdrDate());
                              goodTable.addCell(c);
                              goodTable.addCell(sale.getRefNumber());
                             j++;
                document.add(goodTable);
                // add text at an absolute position
                document.close();
            } catch (Exception ex) {
                System.err.println(ex.getMessage());
        }

  • How to create the chart using java

    Hi Friends,
    I have one urgent requirement.I need to create the chart by using the table value.The value is stored in database like as follow..
    Attribute     IG
    Home     0.05
    Married     0.72
    Gender     0.05
    Employed     0.05
    Rate      0.05
    I need to get the highest value and create the parent node and lowest value is child node llike that i need create ...
    plz any body help me....

    You don't do that using Java.
    Consult the documentation of the application server in question how to configure it. If you're using for example Tomcat 6.0, then you should be consulting this document: [http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html].

  • How to create poll functionality using java(struts)

    Hiii,
    How to create the poll functionality to place into the site. I am using struts and XML file to store the data. We should able to view the result of the poll in horizontal bar graph.
    Please give me an idea how to implement it or provide a link which has the implementation.
    Thanks

    Whatever happened to good, old-fashioned thinking? All we see here now is "how to write <common application> with minimal input from myself?"-type questions. It's only a matter of time until we get people coming here asking "how to write <massively-scoped enterprise app>? What class I need for that?". Oh, wait. We already do get that

  • How to create mysql backup using java

    please i am trying to create a backup of my database using mysqldump with the runtime class. But it is not working out. Please can anyone give me a code that creates mysql backup in java?. I will be grateful.

    It might help to know what
    ushahemba wrote:
    it is not working outmeans.
    Please can anyone give me a code that creates mysql backup in java?.Now, I'm sorry, but why should anyone do your work for you?
    Read this thoroughly and conpletely, and implement the recommendations there.

Maybe you are looking for