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 5 of 5

Thread: onchange does not work

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Location
    Kochi,India
    Posts
    18
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default onchange does not work

    i've a jsp with two html:text elements namely Fromdate and To date. These are intended for user to input datetime values. Next to these text boxes, calendar images are placed. Upon clicking the image the javascript:CSS calendar utility is invoked and it returns the selected date and time which is inserted to these text boxes. Everything was fine, till I added an onchange javascript function to the second text box. This js function calls an ajax method to check whether these values exist in the database. It also checks whether the dates are in correct sequential order. If the JS function returns false, the JSP page should not be forwarded. The functions are returning proper values, but even if the js function return false, the record gets added.

    The following is my code:
    HTML Code:
    <tr>
    	       	<td align="left" height="27">   From</td>
    	       	<td align="left"><html:text name="myvo" property="fromDate" size="18"/>
    	    	             <a href="javascript:NewCssCal('fromDate','ddmmyyyy','dropdown',true)"><img src="img/cal.gif" width="16" height="16" alt="Pick a date"></a>
    			</td>
        	</tr>
    		<tr>
    	       	<td align="left" height="27">     To</td>
    	       	<td align="left"><html:text name="myvo" property="toDate" size="18" onchange="return dutyChecker('No','msgarea','2')"/>
    	    	             <a href="javascript:NewCssCal('toDate','ddmmyyyy','dropdown',true)"><img src="img/cal.gif" width="16" height="16" alt="Pick a date"></a>
    			</td>
        	</tr>
    am i missing something here? Or should I change the "onchange" to someother?

    Kindly help


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: onchange does not work

    How about you try either onkeypress, onkeyup or onkeydown.

    I'm not sure onchange is triggered in all browsers for an input text field.

    // Json

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Location
    Kochi,India
    Posts
    18
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: onchange does not work

    onkeyup is also not working. See, my intention is to invoke this javascript function on the lostfocus of the second text box. This function should be invoked in all cases ie. when the user fills the text box with keyboard input as well as by clicking on the calendar image. Which is the best option to ensure that this function is invoked regardless of the method of input?

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: onchange does not work

    How about adding an onblur to that second text box instead then

    Otherwise you might have to bind to many of these event to ensure that the method will get run.

    // Json

  5. The Following User Says Thank You to Json For This Useful Post:

    jai (March 9th, 2011)

  6. #5
    Junior Member
    Join Date
    Feb 2011
    Location
    Kochi,India
    Posts
    18
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: onchange does not work

    thanks..used onblur and it made a difference..

Similar Threads

  1. MergeSort won't work
    By joshft91 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: February 7th, 2011, 09:44 PM
  2. How do get and set methods work??
    By merdzins in forum Object Oriented Programming
    Replies: 2
    Last Post: December 25th, 2010, 03:17 AM
  3. please tell me why this code does not work
    By amr in forum Java Theory & Questions
    Replies: 9
    Last Post: December 6th, 2010, 06:46 PM
  4. home work ..
    By shane1987 in forum Collections and Generics
    Replies: 8
    Last Post: November 16th, 2010, 09:45 AM
  5. Why won't this while loop work?
    By trueblue in forum Loops & Control Statements
    Replies: 2
    Last Post: July 17th, 2009, 09:10 AM