Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Click button not working

  1. #1
    Junior Member
    Join Date
    Jul 2021
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Click button not working

    Here is my coding, which I want to input first name and last name and then press the Save button. but when press the save button, seems the coding is not working and take effective. Can anyone suggest what's wrong on my coding? Or any suggestion? Thanks.

    Program Coding :

    <div class="form-r">
    <label> First Name :</label><input type="text" id="first">
    </div>

    <div class="form-r">
    <label> Last Name :</label><input type="text" id="last">
    </div>

    <div class="form-r">
    <button id="butn"> Save</button>
    </div>

    <script>
    Logger.log('before press butn');
    document.getElementById("butn").addEventListenser( "click",dosumthing);

    function dosumthing(){
    Logger.log('press butn');
    document.getElementById("first").value="";
    document.getElementById("last").value="";
    // var userInfo={};
    // userInfo.firstname=document.getElementById("first" ).value;
    // userInfo.lastname=document.getElementById("last"). value;
    // google.script.run.userClicked(userInfo);
    }

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java Click button not working

    This code looks like javascript which is not the same as java.
    Try asking the question on a forum for javascript.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java matching colours game (second click not working)
    By cloud__ in forum What's Wrong With My Code?
    Replies: 16
    Last Post: March 28th, 2019, 01:59 PM
  2. Newbie to Java trying to open VM with button click
    By madmarf in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 2nd, 2017, 01:42 PM
  3. How to display an image to a click of a button
    By syedjavidali in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 4th, 2014, 08:28 AM
  4. add JTextField with a click of button
    By A4Andy in forum AWT / Java Swing
    Replies: 1
    Last Post: August 31st, 2011, 07:34 AM