Skip to Content
avatar image
Former Member

Dynamic text fied input

Hi,

I have a view which display a input field to fill voucher code and there is a button to click if user wants to enter more vouchers, on click of that button another input field appeared. I have done this in view like below -

var oVoucherLabel = new sap.m.Label({ text : "Voucher Code:" })

var oVoucherCodeInput = new sap.m.Input(this .createId("WorkArea-HD1-VoucherCode"), { type : "Text", })

var addMoreVoucherBtn = new sap.m.Button({ id : "WorkArea-HD1-AddVoucher", text : "Add Voucher",

press : function(){

oVerticalLayout1.addContent

(new sap.m.Input({type : "Text"}))}

var getApplyDiscountBtn = new sap.m.Button({ id : "WorkArea-HD1-UpdatePrice", text : "Apply discount" })

getApplyDiscountBtn.attachPress(oController.OnPressApplyDiscount, oController);

Here I have added input field on press of the function of addMoreVoucherBtn to display a input field on each click of button.

Now I am struggling to get the value of the input field added on the press event in controller file as it can have multiple values depending on the number of times button has pressed. Please suggest..

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Nov 16, 2017 at 01:01 PM

    Hi Swathi,

    First add the First Label and respective input field in Vertical Layout.

    After that the add the add more voucher input field to the same vertical Layout.

    Now to fetch the input values first get all the contents available in Vertical layout .then after you can get the Input fields available in the Vertical Layout by looping.

    Add comment
    10|10000 characters needed characters exceeded