You need to sign in to do that
Don't have an account?
DelMerchandise Compile Error: unexpected token: 'products' at line 26 column 81
Hi ,
My apex code :
public class DelMerchandise {
int i;
public string[] products=new string[]{};
public string[] getproducts() {
return products;
}
public void setproducts(string[] products){
this.products=products;
}
public List<SelectOption> getproductslist() {
list <SelectOption> options=new list <SelectOption>();
for(Merchandise__c items:[select name ,price__c from Merchandise__c ])
{
options.add(new SelectOption(String.valueof(items.price__c),items.name ));
}
return options;
}
public pagereference del()
{
for(i=0;i<products.length;i++)
{
List <Merchandise__c> del1 =[ select name from Merchandise__c where name=products[i]];
delete del1;
}
PageReference pageref=page.deletedsuccess;
return pageref;
}
I got error in marked line .....
My Visual force code :
<apex:page standardStylesheets="false" showHeader="false" sidebar="false" readOnly="true"
controller="DelMerchandise" >
<br/><br/>
<h2 > Select the product to delete :</h2><br/><br/>
<apex:stylesheet value="{!URLFOR($Resource.milestone_stylshet, 'style.css')}"/>
<apex:form >
<apex:selectCheckboxes value="{!products}" layout="pageDirection">
<apex:selectOptions value="{!productslist}" />
</apex:selectCheckboxes><br/><br/>
<apex:commandButton action="{!del}" value="Delete"/>
</apex:form>
</apex:page>
.....Any solution ?....
thanks ,
jana
Hi,
Put the colon before products[i] then it works fine,
List <Merchandise__c> del1 =[ select name from Merchandise__c where name=:products[i]];
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.