newbie27
asked on
jQuery, comparing 2 strings
Hello Folks,
I am capturing SELECT element and Textbox values and I am trying to comparing it to check if they are equal like this
if($("#drpLists").val() == $("#txtListname").val()){
$("#hiddflag").val('2');
}
is this not correct?
please advice
thanks
s
I am capturing SELECT element and Textbox values and I am trying to comparing it to check if they are equal like this
if($("#drpLists").val() == $("#txtListname").val()){
$("#hiddflag").val('2');
}
is this not correct?
please advice
thanks
s
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hello Guys,
Thanks for your comments, Please see my code attached hopefully you may get to see what I am trying to do here.
Just to give you an overview I am calling addToList() function , wanted to do some validations and based on them passing appropriate flag values ($("#hiddflag").val('2')) to the proxy page to process by calling submitForm() function.
but it is not passing appropriate hidden values in the ajax call.
Thanks for looking.
Regards
Sam
Thanks for your comments, Please see my code attached hopefully you may get to see what I am trying to do here.
Just to give you an overview I am calling addToList() function , wanted to do some validations and based on them passing appropriate flag values ($("#hiddflag").val('2')) to the proxy page to process by calling submitForm() function.
but it is not passing appropriate hidden values in the ajax call.
Thanks for looking.
Regards
Sam
function addToList()
{
if($("#drpLists").val() == 0){
alert('Please select a list');
}else if($("#drpLists").val() == "new" && $("#txtListName").val() == ""){
alert('Please enter List Name');
}else{
if($("#drpLists").val() == "new" && $("#txtListName").val() != ""){
$("#hiddflag").val('0');
}else if($("#drpLists").val() != "new" && $("#txtListName").val() == ""){
$("#hiddflag").val('1');
}else if($("#drpLists").val() == $("#txtListName").val()){
$("#hiddflag").val('2');
}
var result = "";
$(".chkRefNos").each( function ()
{
if(this.checked == true) {
result += "," + $(this).val() ;
}
});
result = result.substr(1);
if( result ){
submitForm('frmList', 'savefields');
} else{
checkAll("on");
submitForm('frmList', 'savefields');
}
}
//return false;
}
function submitForm(frm, ax){
// requires jquery
$('#action').val(ax);
var myForm = $("#" + frm);
var param="";
$(".edit_area").each( function(){param+= "," + escape(this.innerHTML) });
param = "itemNotes=" + param.substring(1);
var frmParams = myForm.serialize() + "&" + param;
$.ajax({
type: "POST",
url: "list_save_proxy.asp",
dataType: "xml",
data: frmParams,
success: function(xml){
var errCode = $("errorcode", xml).text();
var errMsg = $("errormsg", xml).text();
var resTxt = $("responsetext", xml).text();
if(errCode == 0){
if(resTxt =="exist"){
if(confirm('List Name Already exist, Do you want to over write it?')){
submitForm('frmList', 'savefields');
$("#hiddflag").val('4');
}
}else{
$('#responsemsg').html(resTxt);
repopulateList();
}
}else{
$('#responsemsg').html('\n<br> > ' + resTxt + '');
$('#responsemsg').append(' [' + errCode + ' ' + errMsg + ']');
}
}
});
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Yeah you are right I actually have not set the hiddFlag value in the HTML correctly but it is now seems to be working ....!!
However, I am now facing problems in displaying correct data in the Flexigrid. All I am doing there is to pick the name from <SELECT> and when I click on View list button I am doing an Ajax call to show details of selected option in the Grid.
But it is not doing it right.
Can you please have a look it here
https://www.experts-exchange.com/questions/23471788/jquery-flexigrid-not-getting-updated-on-onClick-event.html
thanks for your help
sam
However, I am now facing problems in displaying correct data in the Flexigrid. All I am doing there is to pick the name from <SELECT> and when I click on View list button I am doing an Ajax call to show details of selected option in the Grid.
But it is not doing it right.
Can you please have a look it here
https://www.experts-exchange.com/questions/23471788/jquery-flexigrid-not-getting-updated-on-onClick-event.html
thanks for your help
sam
ASKER
thanks
No worries - glad to help.
Open in new window