boolean test = true;// my loop starts here and i want to be able to loop the //switch statement when non of the cases are selected, I want the loop to go to back to case 1 after displaying the error message.
while (test)
Proceed = Next.nextInt();
switch (Proceed) {
case 1:// Proceed
System.out.println("Please enter your 5 digit pin below.");
Scanner Pin = new Scanner(System.in);
int Pincode = Pin.nextInt();
if (Pincode > 9999 && Pincode < 99999) {
System.out.println("1)Display Balance");
System.out.println("2)Withdraw Cash");
System.out.println("3)Other services");
} else {
System.err
.println("Sorry,the pin you enterd was incorrect\nyour card is being ejected\nPlease wait...");
}
test=false;
break;
case 2:// Return Card
System.err.println("Your card is being ejected.\n Please Wait..");
test=false;
break;
default: // i want to display this message and send it back to case 1. when i do the method i'm doing it just keeps spamming this message.
System.err.println("Sorry your request could not be processed.Please re-try");
test=true;
}
If you want to send it back to case 1 then you need to set proceed to 1. I'm guessing that Next.nextInt() will give you 1, 2 but then 3 and then 4, etc. And anything over 2 will go to the default case
I would like to filter a product based on size, color with (or) operator in Shopify and multiple options. This feature is not yet available in Shopify. Here is a sample link (non Shopify store) http://www.myntra.com/women-sandals?src=tn&nav_id=147.
I have tried with the following example, it does work for price (between 200 to 300 and 300 to 400 price) class.
$( "#price input[type='checkbox']" ).change( function() {
var str_all= $("#all").attr("checked");
var str_200_300= $("#200-300").attr("checked");
var str_300_400= $("#300-400").attr("checked");
var case_id;
if(str_all=="checked") {
case_id=1;
}else if((str_200_300=="checked") && (str_300_400=="checked")) {
case_id=4;
}else if(str_200_300=="checked") {
case_id=2;
}else if(str_300_400=="checked") {
case_id=3;
}else {
case_id=5;
}
switch(case_id) {
case 1:
$('.300-400').show(500);
$('.200-300').show(500);
break;
case 2:
$('.200-300').show(500);
$('.300-400').hide(500);
break;
case 3:
$('.200-300').hide(500);
$('.300-400').show(500);
break;
case 4:
$('.300-400').show(500);
$('.200-300').show(500);
break;
case 5:
$('.300-400').show(500);
$('.200-300').show(500);
break;
}
});
Use Powertools Shopify App for filters.
Power Tools can assist in basic tasks, automate processes and add new features to your store. It's a commercial app, but you can use the Free Trial which is 5 days.
I am using JQGrid v4.4.1 and MVC3.
When Selecting the 'Next Record' or 'Previous Record' icon on The JQGrid Edit Form, I get a Microsoft JScript runtime error: Object doesn't support property of method 'split'.
If highlights a block of code in the jquery.jqgrid.min.js module : var j=g.split(",")
Sometimes intellesense says that g=0, other times it's -2: I guess it's data related, but i cannot see anything that could be causing this!
I've tried to include a section of this module, including this call, but I'm struggling to make head nor tailof it!
Can anyone help me in determining the cause of this error?
jquery.jqGrid.min.js Extract
2*k+"'>"+t.rowcontent+"</td></tr>"),a(h).append(r),r[0].rp=u);0===m.length&&(m=a("<tr "+q+" rowpos='"+u+"'></tr>").addClass("FormData").attr("id","tr_"+f),a(m).append(p),a(h).append(m),m[0].rp=u);a("td:eq("+(y-2)+")",m[0]).html("undefined"===typeof t.label?e.p.colNames[o]:t.label);a("td:eq("+(y-1)+")",m[0]).append(t.elmprefix).append(l).append(t.elmsuffix);n[j]=o;j++}});if(0<j&&(o=a("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='"+(2*k-1)+"' class='DataTD'><input class='FormElement' id='id_g' type='text' name='"+
e.p.id+"_id' value='"+d+"'/></td></tr>"),o[0].rp=j+999,a(h).append(o),c[b.p.id].checkOnSubmit||c[b.p.id].checkOnUpdate))c[b.p.id]._savedData[e.p.id+"_id"]=d;return n}function r(d,e,h){var f,k=0,g,m,j,q,l;if(c[b.p.id].checkOnSubmit||c[b.p.id].checkOnUpdate)c[b.p.id]._savedData={},c[b.p.id]._savedData[e.p.id+"_id"]=d;var o=e.p.colModel;if("_empty"==d)a(o).each(function(){f=this.name;j=a.extend({},this.editoptions||{});if((m=a("#"+a.jgrid.jqID(f),"#"+h))&&m.length&&null!==m[0])if(q="",j.defaultValue?
(q=a.isFunction(j.defaultValue)?j.defaultValue.call(b):j.defaultValue,"checkbox"==m[0].type?(l=q.toLowerCase(),0>l.search(/(false|0|no|off|undefined)/i)&&""!==l?(m[0].checked=!0,m[0].defaultChecked=!0,m[0].value=q):(m[0].checked=!1,m[0].defaultChecked=!1)):m.val(q)):"checkbox"==m[0].type?(m[0].checked=!1,m[0].defaultChecked=!1,q=a(m).attr("offval")):m[0].type&&"select"==m[0].type.substr(0,6)?m[0].selectedIndex=0:m.val(q),!0===c[b.p.id].checkOnSubmit||c[b.p.id].checkOnUpdate)c[b.p.id]._savedData[f]=
q}),a("#id_g","#"+h).val(d);else{var n=a(e).jqGrid("getInd",d,!0);n&&(a('td[role="gridcell"]',n).each(function(m){f=o[m].name;if("cb"!==f&&"subgrid"!==f&&"rn"!==f&&!0===o[m].editable){if(f==e.p.ExpandColumn&&!0===e.p.treeGrid)g=a(this).text();else try{g=a.unformat.call(e,a(this),{rowId:d,colModel:o[m]},m)}catch(i){g="textarea"==o[m].edittype?a(this).text():a(this).html()}b.p.autoencode&&(g=a.jgrid.htmlDecode(g));if(!0===c[b.p.id].checkOnSubmit||c[b.p.id].checkOnUpdate)c[b.p.id]._savedData[f]=g;f=
a.jgrid.jqID(f);switch(o[m].edittype){case "password":case "text":case "button":case "image":case "textarea":if(" "==g||" "==g||1==g.length&&160==g.charCodeAt(0))g="";a("#"+f,"#"+h).val(g);break;case "select":var j=g.split(","),j=a.map(j,function(b){return a.trim(b)});a("#"+f+" option","#"+h).each(function(){this.selected=!o[m].editoptions.multiple&&(a.trim(g)==a.trim(a(this).text())||j[0]==a.trim(a(this).text())||j[0]==a.trim(a(this).val()))?!0:o[m].editoptions.multiple?-1<a.inArray(a.trim(a(this).text()),
j)||-1<a.inArray(a.trim(a(this).val()),j)?!0:!1:!1});break;case "checkbox":g+="";o[m].editoptions&&o[m].editoptions.value?o[m].editoptions.value.split(":")[0]==g?(a("#"+f,"#"+h)[b.p.useProp?"prop":"attr"]("checked",!0),a("#"+f,"#"+h)[b.p.useProp?"prop":"attr"]("defaultChecked",!0)):(a("#"+f,"#"+h)[b.p.useProp?"prop":"attr"]("checked",!1),a("#"+f,"#"+h)[b.p.useProp?"prop":"attr"]("defaultChecked",!1)):(g=g.toLowerCase(),0>g.search(/(false|0|no|off|undefined)/i)&&""!==g?(a("#"+f,"#"+h)[b.p.useProp?
"prop":"attr"]("checked",!0),a("#"+f,"#"+h)[b.p.useProp?"prop":"attr"]("defaultChecked",!0)):(a("#"+f,"#"+h)[b.p.useProp?"prop":"attr"]("checked",!1),a("#"+f,"#"+h)[b.p.useProp?"prop":"attr"]("defaultChecked",!1)));break;case "custom":try{if(o[m].editoptions&&a.isFunction(o[m].editoptions.custom_value))o[m].editoptions.custom_value.call(b,a("#"+f,"#"+h),"set",g);else throw"e1";}catch(q){"e1"==q?a.jgrid.info_dialog(jQuery.jgrid.errors.errcap,"function 'custom_value' "+a.jgrid.edit.msg.nodefined,jQuery.jgrid.edit.bClose):
a.jgrid.info_dialog(jQuery.jgrid.errors.errcap,q.message,jQuery.jgrid.edit.bClose)}}k++}}),0<k&&a("#id_g",i).val(d))}}function u(){a.each(b.p.colModel,function(a,b){b.editoptions&&!0===b.editoptions.NullIfEmpty&&k.hasOwnProperty(b.name)&&""===k[b.name]&&(k[b.name]="null")})}function t(){var e,f=[!0,"",""],m={},g=b.p.prmNames,j,o,l,n,v,p=a(b).triggerHandler("jqGridAddEditBeforeCheckValues",[a("#"+h),z]);p&&"object"===typeof p&&(k=p);a.isFunction(c[b.p.id].beforeCheckValues)&&(p=c[b.p.id].beforeCheckValues.call(b,
k,a("#"+h),"_empty"==k[b.p.id+"_id"]?g.addoper:g.editoper))&&"object"===typeof p&&(k=p);for(l in k)if(k.hasOwnProperty(l)&&(f=a.jgrid.checkValues.call(b,k[l],l,b),!1===f[0]))break;u();f[0]&&(m=a(b).triggerHandler("jqGridAddEditClickSubmit",[c[b.p.id],k,z]),void 0===m&&a.isFunction(c[b.p.id].onclickSubmit)&&(m=c[b.p.id].onclickSubmit.call(b,c[b.p.id],k)||{}),f=a(b).triggerHandler("jqGridAddEditBeforeSubmit",[k,a("#"+h),z]),void 0===f&&(f=[!0,"",""]),f[0]&&a.isFunction(c[b.p.id].beforeSubmit)&&(f=c[b.p.id].beforeSubmit.call(b,
k,a("#"+h))));if(f[0]&&!c[b.p.id].processing){c[b.p.id].processing=!0;a("#sData",i+"_2").addClass("ui-state-active");o=g.oper;j=g.id;k[o]="_empty"==a.trim(k[b.p.id+"_id"])?g.addoper:g.editoper;k[o]!=g.addoper?k[j]=k[b.p.id+"_id"]:void 0===k[j]&&(k[j]=k[b.p.id+"_id"]);delete k[b.p.id+"_id"];k=a.extend(k,c[b.p.id].editData,m);if(!0===b.p.treeGrid)for(v in k[o]==g.addoper&&(n=a(b).jqGrid("getGridParam","selrow"),k["adjacency"==b.p.treeGridModel?b.p.treeReader.parent_id_field:"parent_id"]=n),b.p.treeReader)b.p.treeReader.hasOwnProperty(v)&&
(m=b.p.treeReader[v],k.hasOwnProperty(m)&&!(k[o]==g.addoper&&"parent_id_
After Oleg pointed me in the right direction (thanks Oleg!). I have managed to resolve this Error.
Using The jquery.jqgrid.src.js (much more readable) I managed to take an educated guess that the problem lay on a column in my Grid that was using a FORMATTER. I then noticed that even when loading the Edit form - the value for this column was not correct - and bacause The edittype was 'select', it was defaulting to the first item in the value list.
The Formatter would take the Value of the column (which could be either a -2, 0 or 1 in this case) and turn it into a gif for display purposes in the column. that worked lovely.
The UnFormatter, however, attempted to turn the image back into it's respective number (based on its title). I was then returning a numeric value ( ie. -2, 0 or 1). I needed to return a string value. (ie. '-2','0' or '1')
So, it seems that for Unformatters, you cannot return numeric values like this.
I have added the working code below for clarity :)
Working formatters
function EnabledFormatter(cellvalue, options, rowObject) {
var cellValueInt = parseInt(cellvalue);
switch (cellValueInt)
{
case 1:
return "<img src='#Url.Content("~/Content/images/tick.gif")' title='Enabled' />";
break;
case -2:
return "<img src='#Url.Content("~/Content/images/tick-grey.png")' title='Inherited' />";
break;
default:
return "<img src='#Url.Content("~/Content/images/cross.gif")' title='Disabled' />";
break;
};
};
function EnabledUnformatter (cellvalue, options, cell) {
var sTitle = $('img', cell).attr('title');
switch (sTitle)
{
case 'Enabled':
return '1';
break;
case 'Inherited':
return '-2';
break;
default:
return '0';
break;
};
};
Broken Unformatter Please note The lack of '' around the values returned. The EnabledFormatter is Unchanged
function EnabledUnformatter (cellvalue, options, cell) {
var sTitle = $('img', cell).attr('title');
switch (sTitle)
{
case 'Enabled':
return 1;
break;
case 'Inherited':
return -2;
break;
default:
return 0;
break;
};
};
I'm fairly new to Coldfusion, we are using MX 7, and i'm trying to figure out how to populate a page based on user input. The goal is to have the user specify how many products they want to input into an order form and display that many textfields.
Any help would be appreciated.
EDIT: I found how to do this using jQuery but i'm still having a problem populating the textfields with information from the database. Here is what I have:
function fillfields(oSel){
var oForm=oSel.form;
switch(oSel.options[oSel.selectedIndex].value){
case '0': break;
case'1':oForm.ShipCompany2.value="#company_name.Company#";
oForm.ShipName2.value="#company_name.Name#";
oForm.ShipLine3.value="#company_name.Address1#";
oFrom.ShipLine4.value="#company_name.Address2#";
oForm.ShipCity2.value="#company_name.City#";
oForm.ShipState2.value="#company_name.State#";
oForm.ShipZipcode2.value="#company_name.ZipCode#";
break;
case '2':
break;
case '3':
break;
}
}
This won't work. Is there another way to populate this?
Somewhere in your CFM page, you have code that looks like:
function fillfields(oSel){
var oForm=oSel.form;
switch(oSel.options[oSel.selectedIndex].value){
case '0': break;
case'1':oForm.ShipCompany2.value="#company_name.Company#";
oForm.ShipName2.value="#company_name.Name#";
oForm.ShipLine3.value="#company_name.Address1#";
oFrom.ShipLine4.value="#company_name.Address2#";
oForm.ShipCity2.value="#company_name.City#";
oForm.ShipState2.value="#company_name.State#";
oForm.ShipZipcode2.value="#company_name.ZipCode#";
break;
case '2':
break;
case '3':
break;
}
}
Modify this to:
<cfoutput>
function fillfields(oSel){
var oForm=oSel.form;
switch(oSel.options[oSel.selectedIndex].value){
case '0': break;
case'1':oForm.ShipCompany2.value="#company_name.Company#";
oForm.ShipName2.value="#company_name.Name#";
oForm.ShipLine3.value="#company_name.Address1#";
oFrom.ShipLine4.value="#company_name.Address2#";
oForm.ShipCity2.value="#company_name.City#";
oForm.ShipState2.value="#company_name.State#";
oForm.ShipZipcode2.value="#company_name.ZipCode#";
break;
case '2':
break;
case '3':
break;
}
}
</cfoutput>
This will pick up the fields from the company_name structure, assuming that the company_name struture exists when you are rendering this section of code.