+ Start a Discussion
Surya KiranSurya Kiran 

How to Access Output Field (Inline edit enabled) values using javascript from Visualforce page

Hi,

I want to access Output field values from javascript. when I was accessing that record from visualforce page I enabled Inline edit for that field. I used document.getElementById("").InnerHTML. But I am getting entire innerHTML properties with span and div tags instead of text.

Any Ideas for this.
Best Answer chosen by Surya Kiran
Surya KiranSurya Kiran
Thanks for your replies.

I got the solution.

var selectedValue = document.getElementById("id").options[document.getElementById("id").selectedIndex].value;

All Answers

Vamsi KrishnaVamsi Krishna
Surya,
you can try using document.getElementById("").value and see if it gets you only the value..
lakslaks
I haven't tried by enabling Inline edit, otherwise the following method works :

Sample:
<apex:outputText Id="unitPrice"....>

Invocation of js function - onblur = "compute('{!$Component.unitPrice}');"

JS function -

function compute(unitPriceId)
{
var cost = document.getElementById(unitPriceId).innerHTML;          
............

}
Surya KiranSurya Kiran
Hi Vamsi / laks,

document.getElementById("").value is not working incase of Output fields. It is working for Input fields.

When coming to .innerHTML it is working for only output fields without inline edit. If I enabled Inline edit its not giving an exact value.

<apex:outputField value="{!Object.field}" >
      <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass"           resetFunction="resetInlineEdit"/>
</apex:outputField>
Surya KiranSurya Kiran
Thanks for your replies.

I got the solution.

var selectedValue = document.getElementById("id").options[document.getElementById("id").selectedIndex].value;
This was selected as the best answer