function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Swamy PSwamy P 

How to Update Child Records in visualforce page with out controller

Hello Folks,

I'm working in Professional Edition. So i don't have access for Apex. I was trying to update Contact Records from an Account Page by using Custom button(Through VF Page). 

As i understood that we can query the records by using sforce.connection.query and also we can update by using sforce.connection.update.  I need help on how to add list in vf page from a javascript.

<apex:PagebolckTable value="{!contactsForAccount}" var="c">  Showing Contact Records in editable mode in a visualforce page
    <apex:column headervalue="Last Name">
         <apex:inputfield value="{!c.LastName}"/>
    </apex:column>
</apex:PagebolckTable>

contactsForAccount - > It is the list adding in PageBlock Table, how to add records to this list in PageBlock Table.
pconpcon
Once you have the data in JavaScript you will need to inject it into the page via the DOM.  You can do this directly or you can use a library like jQuery [1].  Then you would just create the HTML you need (including any buttons /binding to fire the updates).
Swamy PSwamy P
Hello buddy,
Will you provide sample code that how to push data from javascript to a List(which is in PageblockTable).
 
pconpcon
You won't push the data to the list (since you cannot use Apex).  You will have to generate the HTML.  Below is an example using jQuery [1] (sorry for forgetting the link earlier).

Assuming you have the following Visualforce page:
 
<apex:includeScript value="//code.jquery.com/jquery-1.11.3.min.js" />
<apex:pageBlock>
    <apex:pageBlockTable value="{!Account.Contacts}" var="con" id="contactTable">
        <apex:column value="{!con.Name}" />
    </apex:pageBlockTable>
</apex:pageBlock>

The key points of the code above is including the jQuery script and setting the id on the pageBlockTable

Then from your JavaScript you can make the following call to append the data
 
var contactName = 'Bob Dole';

jQuery("[id$='contactTable'] tbody").append('<tr><td>' + contactName + '</td></tr>');

This will append a new row into your table.  I would also recommend that you look over a templating language [2][3].  This would help dramatically in making you JavaScript much more readable and make it easier to modify later.

[1] https://jquery.com/
[2] http://handlebarsjs.com/
[3] http://www.embeddedjs.com/