View Full Version : Alertbox going off only on 2 clicks

12-06-2010, 07:41 AM

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.

12-06-2010, 08:33 AM
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.

12-06-2010, 09:16 AM
The code goes like,

<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();
type: 'POST',
success: function(result)
if(result != 0)
var string = result;
var string_result = string.split("_");
alert('This can be entered only once');

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'>");
$("#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??

12-07-2010, 04:21 AM
Please provide a solution to my problem