+ Start a Discussion

Java script to update the input field of an object on VF page

I created a VF page with input fields of Account Object. I created a select list on Vf page using controller. I want to update the input field(selected__c : datatype--text) with same value selected option in select list.

I tried below code but it is not working as i am making mistake somewhere.
Can anyone help me with this .

<apex:selectList value="{!selectedVal}" multiselect="false" readonly="true"  onchange="updateField()" size="1" id="ddlViewBy">
<apex:selectOptions id="selectid" value="{!contact}"/>
<apex:inputfield id="customfield" value="{!Account.Match__c}"></apex:inputfield>
 function updateField() {
 var e = document.getElementById("ddlViewBy");
 var strUser = e.options[e.selectedIndex].value;
 document.getElementById("customfield") = strUser;

Controller :
public List<SelectOption> getcontact() {   
    List<SelectOption> options = new List<SelectOption>();
     Account a = [Select id,Name,OwnerId,Match__C FROM Account where id =: this.account.id]; 
   con  = [Select id, Name from Contact  where OwnerId =: a.OwnerId];
    if (con.Size() >0)
    for(Contact c : con){
    if (c.Name != null)
      options.add(new SelectOption(c.Name,c.Name));
   return options;