Is it possible to do something like this - would like to sub in a form field value with this javascript code. Can it be done, not sure if it is a syntax thing or just not possible.
The 5<18 was just something I put in there that would evaluate as true - not the question I have.
On my site I use this code to copy a lot of info to the clipboard on a button click
<script>
function myFunction() {
var copyText = document.getElementById("myInput" + form1.flourstomix.value);
copyText.select();
document.execCommand("copy");
alert("Copied To Clipboard: " + '\n' + copyText.value);
}
</script>
example of the info below - I’m trying to come up with a way to not copy the lines that have zero values for the form fields. I was thinking I could use javascript somehow and a bunch of concatenate string commands and wanted to see if I could get the form values to become part of the string.
I think you question just goes a little out of the parameters of why Wappler even exists, using App Connect as a framework you should not even have to use things like document.getElementById.
You have a button on your page you say, and onclick it fires the copy to clipboard stuff, therefore you can add more to that onclick event if you need to, such as setValue, click your button for the copy in design view and find the Dynamic Events in the properties panel, there is probably an onclick event in there, click the lightening bolt icon and see if you can find your form inputs in there, you will notice that you can use a set value to set and value you like to an input on click.
Thanks Paul, I think I’m just not doing a good job of explaining what I’m trying to do but I’ll try to work through what you mentioned (to the best of my ability). I’m not trying to set anything, rather I’m trying not to copy information that is not relevant (when a value is zero).
Likely I need to figure out a better way to do what I’m doing now. I thought I could just hide stuff (if the values were zero) and that would keep it / them from being copied but that did not work, hidden or not, stuff gets copied…
Getting my head wrapped around this is proving very hard for me - I don’t ever remember me trying to do something for months and not have it click - I guess when you get old things don’t work the way they used to. Hope my brain is not turning into mush
Well i understand better now. Basically you only want to copy values from the form if the value is not zero.
So in reality then this is all to do with your text area where your data is all being stored.
You need a few conditions inside there. Something like this might work
form1.calcweight.value ? 'I have a value'
I’m on my phone so not certain of syntax without testing how this would work in the text area but basically this is a condition saying when form1.calcweight.value has a value then output a string of I have a value. If the input has no value then it should not output anything at all. Well that’s the concept anyway.
Wow, that blows my mind - I need to think about that. I think the problem is I don’t really store the value (at least I don’t think that is what is happening within Wappler).
There are a few different configurations of the “textarea”. Which one selected for copy is not important. But, assuming the 4th one (id=myInput4) is copied, this is what a very abbreviated version of what is copied would look like.
My problem is the stuff in the bound textarea seems out of reach for any manipulation. But I will think very hard about what you said and try to see if I can wrap my head around it and make it work… Thx for not giving up on me Paul!
So I am warning you, if this works i will be very surprised, lol, but worth a try anyway and let me know.
Basically what I am trying to tell it is
is there a value set to form1.preferment.value ? if YES then make a table row with 2 columns inside it saying WOW in column one and IT HAD A VALUE in column two : otherwise / else then make a new table row with 2 columns inside it saying Preferment 000% in column one and 123 in column two.
I know i have it the wrong way around, but lets just test it first to see what happens.
Something in that chuck of code is not working - I replaced a working textarea and added it in its place. That textarea now does not copy anything to the clipboard but all the others still work fine.
I worked for weeks getting what I have working and I know it only takes one missing punctuation mark (or an extra one) to keep the copy from working. That block also causes the error below which I don’t understand.
Tricky when I am working a bit blind here, but lets try this
<textarea id="myInput4" dmx-bind:value="'[table]
' + ((form1.preferment.value == 0 ?) + '[tr][td]WOW[/td][td][right]IT HAD NO VALUE[/right][/td][/tr]
')[/table]'" rows="1" cols="2" style="position:absolute; top:0; left:-500px;"></textarea>
OR
<textarea id="myInput4" dmx-bind:value="'[table]
' + (form1.preferment.value == 0 ?) + '[tr][td]WOW[/td][td][right]IT HAD NO VALUE[/right][/td][/tr]
'[/table]'" rows="1" cols="2" style="position:absolute; top:0; left:-500px;"></textarea>
EDIT: I just checked you site and realised when you said had NO value, that is not really a true statement, as 0 is still a value, its not nothing, so I have adjusted the code a little.
Do your copy to clipboard thing with the preferment left as 0 and it should copy the IT HAD NO VALUE string from one of the above codes.
If it does then we can try to extend on the idea further.
Thats because your original question said they had no value but actually its when value is 0 then dont show and when its not 0 the do whatever, its a small adjustment