Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Alertbox going off only on 2 clicks

    Hi,

    See I have called a function in onchange event of a dropdownlist.What happens in the onchange function is that if the value for dropdown has already been entered once, then an alert message will be shown. The problem I have is, if the value has been already entered, when I try to change the value in dropdown, dropdownlist gets displayed (expands) and an alert message gets displayed. When I click "OK" of alertbox first the dropdown gets back to it original form and only on the next click alert box goes. What I need is everything should happen in a single click itself.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    What I need is everything should happen in a single click itself.
    But we need to see your current code to check whether we can improve it.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts
    The code goes like,
    Code:
    <td>Score <select name="score" id="score"  onchange="wgtage(1);validate_values();"></td>
    
    function validate_values()
    	{
    		var month=$('#month').val();
    		var year=$('#year').val();
    		var eid=$('#emp_id').val();
    		$.ajax({ 
    				url:"abc/valid",
    				data:'month='+month+'&year='+year+'&id='+eid,
    				type: 'POST',
    				success: function(result)
    				{
    					if(result != 0)
    					{
    					var string = result;
    					var string_result = string.split("_");
    					alert('This can be entered only once');
    						$("select#score").val(string_result[0]);
    						$("#actual_score").val(string_result[1]);
    						$("#att_wt").val(string_result[2]);
    						$("select#time").val(string_result[3]);
    						$("#t_actualscore").val(string_result[4]);
    						$("#t_wge_score").val(string_result[5]);
    						$("select#percent").val(string_result[6]);
    						$("#time_actualscore").val(string_result[7]);
    						$("#time_weightage").val(string_result[8]);
    						$("#time_avg").val(string_result[9]);
    						$("#time_wge_avg").val(string_result[10]);
    						
    							if(string_result[11] == 'true')
    							{
    								$("#save_data").html("<input type='button' value='Save' disabled='disabled' onclick='javascript:savetime_details();'/><input type='reset' value='Cancel' disabled='disabled'>");
    							}
    							else
    							{
    								$("#save_data").html("<input type='button' value='Save' class='mybtn2' onclick='javascript:savetime_details();'/><input type='reset' value='Cancel' class='mybtn2'>");
    							}
    					}
    				}
    			});
    	}
    Here the function wgtage() will populate another dropdownlist depending on the value chosen in the above dropdown. I am talking about the alertbox."THIS IS CAN BE ENTERED ONLY ONCE" in the function validate_values().

    Now is it clear??

  • #4
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Please provide a solution to my problem


  •  

    Posting Permissions

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