Is it possible to set value to input with particular selected class? For example, on button click, set value 1 to any input with class-1.
Not sure what you are trying to achieve. Could you give an example?
I want to set value to dynamic input(s) that created dynamically for example by using repeat, but it could be more complicated. So to identify the input(s), I plan to select the input(s) by class instead of name, or id. The input I need to set value could be several and not unique, thus using class selector is my best bet I think.
In short, something like this in jquery but using app connect > dynamic event > set value instead.
$(".class-1").val("1");
Possible?
I am not sure. The way that I am thinking is that there is no Wappler way of doing this and that you will need to rely on JavaScript, as you have shown, to achieve the outcome.
Again try explaining your use case. When you will need this and what your user needs.
The solution might be much easier to present if we understand what you want to serve your user not how you code it.
Alright. Actually this is related to my other post. As explained above, this is what the user needs:
When a button is clicked, the user wants to set value to few inputs with the same class.
I think @ben already understood what I need and as I also aware now, this is not currently possible to be achieved by using visual interface in Wappler.
I’m not sure how can I explain it more easier.
I am trying to understand your need and want to help. Here are some thoughts…
I did not think you could apply a value to a class. A class is a reference to CSS styles.
Do you mean something like this?
You have a series of dynamic values and those values can have one or more classes applied to them.
.red
.green
.orange
.blue
<input type="text" class="red" id="dynamic_input_1">
<input type="text" class="green" id="dynamic_input_2">
<input type="text" class="red blue" id="dynamic_input_3">
<input type="text" class="red orange blue" id="dynamic_input_4">
And so you want to apply the value “1” to all those inputs with class=“blue” and value “2” to all those inputs with class=“orange”?
This doesn’t really make much sense as you already have a unique reference with .red .blue etc.
Can you explain more by supplying a schematic, diagram or written example of what you are wanting to achieve from the user’s point-of-view. Also, where is the data coming from? Is it a database? If so, what is the table and field setup?
Yes I wanted to apply value to input with class xx, but not to apply value to class itself which is weird.
My question above is quite simple and not really a project specific. Thank you anyway.
Hey @transcoderm I know this is an old thread but I am working on something that I need to set values of inputs that are generated dynamically with dynamic IDs. I couldn't see a "Wappler" way to do it with dynamically binded IDs so I wrote a simple jQuery function that is called using the "run javascript" action inside a flow that is run when value changed.
here is the jQuery
/*#####################################
### SET VALUE OF INPUT WITH DYNAMIC ID
#####################################*/
function inputSetValueById(id, valueToSet) {
jQuery('body').find('#' + id).val(valueToSet);
}/*#####################################
### SET VALUE OF INPUT WITH DYNAMIC CLASS
#####################################*/
function inputSetValueByClass(class, valueToSet) {
jQuery('body').find('.' + class).val(valueToSet);
}
Running the function
<script is="dmx-flow" id="flowInputValue" type="text/dmx-flow">{
runJS: {
outputType: "text",
function: "inputSetValueById",
args: ["{{vaInputIdTag.value+'_s'}}", "{{varInputSearchValue.value}}"]
}
}</script>
Hopefully this helps someone in the future.
-Twitch