Notices
Results 1 to 6 of 6

Thread: Html To JAVA

  1. #1 Html To JAVA 
    New Member
    Join Date
    Jul 2006
    Posts
    2
    :?
    I have a questioooooooooonnnnnnnnnnnnnn, Ive posted other places but cant seem to get any replys at all!

    I have an html form that looks a little sumthing like this :

    Suppose that an HTML document contains the following form

    that takes a number from the left input field and outputs its square in the right field upon clicking the button "compute". The form is produced by the following HTML:
    <form name="square" action="#">
    <input type="text" name="number">
    <input type="button" value="compute" onclick="process()">
    <input type="text" name="result">
    </form>

    As it follows from the code, a JavaScript function process() is called if the button is clicked.

    How would i write a javascript code for this function to make the form work?


    Reply With Quote  
     

  2.  
     

  3. #2  
    Forum Freshman
    Join Date
    Jul 2006
    Posts
    5
    Uhmmm I'll try this


    Reply With Quote  
     

  4. #3  
    Forum Freshman
    Join Date
    Jul 2006
    Posts
    5
    <html>
    <head>
    <script type="text/javascript" language="javascript">
    //Defining a parameter-less function that
    // will process the data
    function process(){
    //define two variables one is the value of input
    //the next is the squared value
    var NumToSquare == document.square.number.value
    var Squared = NumToSquare * NumToSquare
    //change the result box to display the value
    document.square.result.value== Squared
    }
    </script>
    </head>
    <body>
    <form name="square" action="#">
    <input type="text" name="number">
    <input type="button" value="compute" onclick="process()">
    <input type="text" name="result">
    </form>
    </body>
    </html>



    I think that's right =/
    Reply With Quote  
     

  5. #4  
    Forum Isotope (In)Sanity's Avatar
    Join Date
    Oct 2004
    Location
    Mesa AZ
    Posts
    2,697
    This may not be directly related, but check out <span> and innerhtml properties.
    Reply With Quote  
     

  6. #5  
    Forum Junior Artemis's Avatar
    Join Date
    Aug 2006
    Location
    Amsterdam
    Posts
    297
    It should work axactly as Jared said. If you want to know more about JavaScript functions i would check:
    http://www.w3schools.com/js/js_functions.asp
    Reply With Quote  
     

  7. #6  
    Forum Sophomore
    Join Date
    Dec 2006
    Posts
    159
    Many other Javascript tutorials are around on the net to download and learn...
    Reply With Quote  
     

Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •