• Shirley2009
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I  have two selectList,list1 and list2. the option of list2 is add according the selected item in list1 automaticly in javascript.

the code is:

 

<script>
 var hotel=new Array();
 var brand=new Array();
 var type=new Array();
 <apex:outputText escape="false" value="{!MyHotel}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyBrand}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyType}"></apex:outputText>
function list2(list2id,n)
{
 var list=document.getElementById(list2id);


 for(var i=list.length-1;i>=0;i--)list.remove(i);
 for(var i=0;i<hotel.length;i++)
 list.add(new Option(hotel[i],hotel[i]));
 }
</script>
<apex:outputPanel id="result">
<apex:form >
<b>Report By: </b>
<apex:selectList id="list1" multiselect="false"  size="1" value="{!reporttype}"  onchange="list2('{!$Component.list2}');">
<apex:selectOption itemValue="1" itemLabel="Hotel"></apex:selectOption>
<apex:selectOption itemValue="2" itemLabel="Hotel Brand"></apex:selectOption>
<apex:selectOption itemValue="3" itemLabel="Hotel Type"></apex:selectOption>
</apex:selectList>
<b>Please select :</b>
<apex:selectList id="list2" multiselect="false" size="1" value="{!reportby}">
</apex:selectList>
<apex:commandButton value="Go!" action="{!doSearch}" status="status"  reRender="result"/>

<apex:form>

</apex:outputPanel >

 

the problem is I can't get the value of reportby in my apex, where is the problem?

I  have two selectList,list1 and list2. the option of list2 is add according the selected item in list1 automaticly in javascript.

the code is:

 

<script>
 var hotel=new Array();
 var brand=new Array();
 var type=new Array();
 <apex:outputText escape="false" value="{!MyHotel}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyBrand}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyType}"></apex:outputText>
function list2(list2id,n)
{
 var list=document.getElementById(list2id);


 for(var i=list.length-1;i>=0;i--)list.remove(i);
 for(var i=0;i<hotel.length;i++)
 list.add(new Option(hotel[i],hotel[i]));
 }
</script>
<apex:outputPanel id="result">
<apex:form >
<b>Report By: </b>
<apex:selectList id="list1" multiselect="false"  size="1" value="{!reporttype}"  onchange="list2('{!$Component.list2}');">
<apex:selectOption itemValue="1" itemLabel="Hotel"></apex:selectOption>
<apex:selectOption itemValue="2" itemLabel="Hotel Brand"></apex:selectOption>
<apex:selectOption itemValue="3" itemLabel="Hotel Type"></apex:selectOption>
</apex:selectList>
<b>Please select :</b>
<apex:selectList id="list2" multiselect="false" size="1" value="{!reportby}">
</apex:selectList>
<apex:commandButton value="Go!" action="{!doSearch}" status="status"  reRender="result"/>

<apex:form>

</apex:outputPanel >

 

the problem is I can't get the value of reportby in my apex, where is the problem?