简体   繁体   中英

Getting dynamic form values

Is there a way to check which like option is selected for which text box when submitted. As shown below user may select like only for some text values. The html tags are dynamically generated based on the object parameters

for(int i = 0 ; i < object ; i++)
{
   if(obj.textbox)
<input type="tex" id="obj.id"/> <input type="checkbox" id="obj.id"+"@"/>
 else
<select> ... </select>
}

Right now what I do is assign a text "@" as shown above to the check box and after the form is submitted iterate all the checkbox items and get the selected value and split it and get the text value and append both value and like if selected, with | symbol and send the request.

Is there a better way to get the entered text values and check if the like option is selected for that.

This is my View Code.

<div  ng-repeat="filter in filters">
<div class="content-pad">
    <fieldset>
        <label for="textinputID1"><p class="lead">
            {{filter.dsply_name}}   :
            </p>
        </label>                    
        <div class="field-group" nowrap>                            
                <input ng-if="!filter.listFlag"  type="text" id='filter.atrbt_name' class="span3">
                <button type="button" class="reset-field hide-text">Reset field</button>
                <label class="checkbox" ng-if="!filter.listFlag">
                    <input id='filter.atrbt_name' type="checkbox">
                    <i class="skin"></i> <span>Like</span> 
                </label>    
        </div>
        <div class="form-row">
            <div class="row-fluid-nowrap">
                <div class="span12">
                    <select ng-if="filter.listFlag" class="mod-select span12" ng-model="filterSelectOption" ng-options="value.displayValue as value.displayValue for value in filter.listValues">
                        <option value="" selected="selected">Select an Option</option>
                    </select>
                </div>
            </div>
            </div>
    </fieldset>
</div>

绑定click事件以提交按钮,在js回调函数中,获取值并进行检查。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM