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
Chidanand MChidanand M 

Add values as we enter into the dynamically created textbox and show the added value in the fixed textbox instantly

Hi folks,

I have a requirement where i need to add the values(like 8,5,6 etc) that r entered into the dynamically created textboxes.
The fixed text box should populate with the added value as v enter the values into the dynamically created textbox.
I have vf and controller.
I just need javascript to perform the the addition of values from the dynamically created textbox instantly as i enter numbers and show in the text box.

TIA
sandeep sankhlasandeep sankhla
Hi Chidu,

You can achieve this by javascript...

You can use onkeypress event and call javascript method...


then you can use document.getelementbyid to get the valye nad assign it to another box...

Thanks
Sandeep
Chidanand MChidanand M
@ Sandeep sankhla

Right. But, the text boxes are created dynamically. And Id's of the dynamically created textboxes will not be known.
So, how to overcome this?? Any sample code plz..
sandeep sankhlasandeep sankhla
Yes, we can bind the event and dynamically id also we can bind to them..based on any unique attribute we can set the ids and then we can access them again for the same..

Thanks
Vivek YadavVivek Yadav
Hi Chidu,

you can go like this:

Add this event while you are dynamically creating the textbox. : onkeyUp="performAction(this)"

<input type="text" onkeyUp="performAction(this)"  id="textBoxId"/> // dynamically created textBox

<script>
function performAction(dynamicElement)
{
    //here you can perform your actions.
    alert(dynamicElement.id);
}
</script>

select this as a best answer if it solve your problem.

Thanks