I am receiving a syntax error; unexpected identifier at line 5. @
dijit.byId("cbRequestType").on('change', function (MFValue) {
if (MFValue == 'Electronic Waste') {
dijit.byID("cbMFSubType").set('value', 'Copy Machine');
}
else if MFValue == '...'{
dijit.by.ID('cbMFSubType').set('value', 'Printer');
}
});
Solved! Go to Solution.
Geoffery,
Try placing your else if condition in parens
- dijit.byId("cbRequestType").on('change', function (MFValue) {
- if (MFValue == 'Electronic Waste') {
- dijit.byID("cbMFSubType").set('value', 'Copy Machine');
- }
- else if (MFValue == '...') {
- dijit.by.ID('cbMFSubType').set('value', 'Printer');
- }
- });
Geoffery,
Try placing your else if condition in parens
- dijit.byId("cbRequestType").on('change', function (MFValue) {
- if (MFValue == 'Electronic Waste') {
- dijit.byID("cbMFSubType").set('value', 'Copy Machine');
- }
- else if (MFValue == '...') {
- dijit.by.ID('cbMFSubType').set('value', 'Printer');
- }
- });
Thank you Robert.
I am getting back around to this, I am fairly novice with JavaScript. The code snippet above is ideal for my application, if E-WASTE is chosen in cbRequestType then cbEWASTE populates with different types of e-waste commodites. See my code below; what could be wrong with this that it does not pass to the combo box? I have a function which populates the e-waste combo box from the feature layer, should this be removed?
(dijit.byId("cbRequestType").on('change', function(MFValue) {
if (MFValue == 'E-WASTE') {
dijit.byID("cbEWASTE").set('value', 'Copy Machine');
}
else if (MFValue == '...') {
dijit.by.ID('cbEWASTE').set('value', 'Printer');
}
});
Geoffery,
So are you trying to set the Combobox selected value (i.e. the CB is already populated with values and you are just trying to set the selected value of the CB)?
Yes, so if cbRequestType is set with E-WASTE then cbSubType is to populate with e-waste types.
Geoffery,
I am still unsure, based on your responses if the cbRequestType combobox ALREADY has the appropriate choices and you just want to select one certain value from it, or do you need to populate the CB with specific values.
I have a function which populates the e-waste combo box from the feature layer, should this be removed?
This makes it sound like you already have the desired values as part of this combobox, but I am not sure this is the case.
Thank you for your help Robert. cbRequestType has the values which are to be passed to the next cb, which I will hardcode and not pass from the feature layer.
So again, if I select E-WASTE from cbRequestType, I'd like cbEWASTE to populate with e-waste types such as copier, scanner, pc, etc. But if WHITE GOODS is selected from cbRequestType I would like my cbEWASTE to populate with white goods types, such as refrigerators, metals, etc.
cbRequestType populates from my feature layer, but based on the script, it would be easier to hard code the statement which links cbRequestType to cbEWASTE.
So I would like to pass a function which populates cbEWASTE on change of cbRequestType...I will have many other fields which follow the same format, so e-waste is just an example...
Geoffery,
I was so confused by your desired workflow I did not see the errors in your code.
dijit.byID is suppose to be dijit.byId (notice capital I only) then in your else you have dijit.by.ID...
Correct code:
(dijit.byId("cbRequestType")).on('change',function(MFValue){
if (MFValue == 'E-WASTE') {
dijit.byId("cbEWASTE").set('value', 'Copy Machine');
} else if (MFValue == '...') {
dijit.byId('cbEWASTE').set('value', 'Printer');
}
});
Not really sure what's incorrect then. I am receiving the error; Uncaught ReferenceError: dijit is not defined serviceRequest.js:1638(anonymous function).