...

View Full Version : Alertbox going off only on 2 clicks



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

abduraooft
12-06-2010, 09: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.

sradha
12-06-2010, 10: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();
$.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??

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum