Results 1 to 6 of 6

Thread: Coding for Button in a JavaScript

  1. #1
    Join Date
    Jul 2006
    Posts
    191

    Coding for Button in a JavaScript

    Hi Friends,
    I am very new to the JavaScript. Before that I have done C++ and Java to some extent. Now I have started working with JavaScript.! In that I want to insert the button. But I don't know the coding of the buttons in JavaScript. I am sure that the coding of the Java and the JavaScript must be different. Instead of searching it on the Web, I thought that posting to you guys would be really useful for me..!!! So please provide me the coding for button in a JavaScript..?? Please reply me soon..!!
    ASUS P5VD1-X
    Intel Pentium Dual Core 3.00GHz
    Maxtor 160GB
    Corsair 1.5GB PC3200 RAM
    Nvidia Geforce 6800 GT 256mb
    Phillips DVD RW
    Magna 500W PSU
    XION II Steel Black Gaming Case

  2. #2
    Join Date
    Aug 2006
    Posts
    227

    Re: Coding for Button in a JavaScript

    Have you just started doing the JavaScript..?? I think that before moving to the coding for the button you should have a look on some basic functions. I think that you should know how to do the coding in JavaScript. So I am giving you an example :
    HTML Code:
    <html>
    <head>
    <title>Have a look on JavaScript</title>
    <script language="JavaScript">
    <!--
    document.write("Hello World!");
    //-->
    </script>
    </head>
    <body> Hello, New User </body>
    </html>
    You should know that the JavaScript code starts with the tag <script language="JavaScript"> and ends with the tag </script>. And the code is placed between <head> and </head>.
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  3. #3
    Join Date
    Jul 2006
    Posts
    286

    Re: Coding for Button in a JavaScript

    In JavaScript, most of the times, you have to specify the version of the JavaScript.
    Code:
    <script language="JavaScript1.2">
    You can also specify another attribute SRC (source) containing the JavaScript code for including an external file. Like you can include the src "hello world.js" in the above example as shown below :
    Code:
    <script language="JavaScript" src="hello world.js"></script>
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  4. #4
    Join Date
    Nov 2008
    Posts
    996

    Re: Coding for Button in a JavaScript

    I am assuming that you know the basic things of coding in JavaScript. For determining the type of the button and the functionality of it when the user clicks on the button, you will have to place the coding into the onClick event. I have provided you with a demonstration that will help you for creating the button in JavaScript :
    Code:
    <SCRIPT language="JavaScript">
    function ShowMessage(Msg)  {
       alert(Msg)
    }
    </SCRIPT>
    <FORM>
    <INPUT type=BUTTON value="Click me!!" onClick="ShowMessage('Successful')">
    </FORM>
    In the above code you will get a message of "Successful". You can change that message according to your need.!!

  5. #5
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Coding for Button in a JavaScript

    I am providing you with the code that are used for the buttons. The following code, should be entered into the head section of your HTML file :
    HTML Code:
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    function onKeyPress () {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (ae) keycode = ae.which;
    else return true;
    if (keycode == 13) {
    alert("Please Click on the Submit button to send this");
    return false
    }
    return true 
    }
    document.onkeypress = onKeyPress;
    </script>
    </HEAD>
    And the following code you will have to insert into the Body section of the HTML file :
    HTML Code:
    <input type="text">
    <input type=submit>
    <p><center>
    <font face="comic sans ms" size"3">Code for JavaScript<br>
    by <a href="http://javascriptsource.com">Hello to Everyone</a></font>
    </center><p>
    Hope that the code helps you..!!!

  6. #6
    Join Date
    Mar 2008
    Posts
    349

    Re: Coding for Button in a JavaScript

    Also for making your form for attractive looks, you should use the images. You should know that the JavaScript button effects are created using images. If you want to display an image, you can use the following HTML code :
    HTML Code:
    <img src="horror.jpg" width="140" height="33" border="1" alt="javascript button">
    To refer this image in the JavaScript, you need to give a name to the image using the 'name' attribute. Just like I did in following example :
    HTML Code:
    <img name="jsbutton" src="horror.jpg" width="140" height="33" border="1" alt="javascript button">

Similar Threads

  1. How to use the pop_heap() in C++ coding
    By Garrick in forum Software Development
    Replies: 4
    Last Post: 05-03-2010, 05:28 PM
  2. Help me to use the transform() in C++ coding
    By Tailor in forum Software Development
    Replies: 5
    Last Post: 19-02-2010, 04:17 PM
  3. Help in coding documents
    By Remedy in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 02:34 AM
  4. javascript keyevents for disabling ctrl button on a webpage
    By AbrahamL in forum Software Development
    Replies: 5
    Last Post: 28-01-2010, 08:54 PM
  5. Javascript function to change the value before submit button
    By Champak in forum Software Development
    Replies: 2
    Last Post: 04-02-2009, 09:50 PM

Tags for this Thread

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
  •  
Page generated in 1,714,145,151.05027 seconds with 16 queries