Copy link to clipboard
Copied
We are working on a form involving many items selected from multiple dropdown menus. We will have multiple text boxes populated each with the items on the drop-down. These text boxes will be used to keep track of the items selected. We need the Text box to strike out the item when it is selected in any of the dropdowns to let the user know they have already used that option. Right now, I can make it work with only one drop down but not the rest. I have the drop-down set to commit the selection immediately and the text box set to Allow Rich Text Format. Each dropdown has to have the full list of items that is why we need to be able to see what they have already selected. This is what I have been using and it works perfectly but only with one drop down when I try to include another nothing happens.
var abn1 = this.getField("Size/Type.0.0.0").value;
if (abn1==" "){
var spans = new Array();
spans[0] = new Object();
spans[1] = new Object();
spans[1].text = "2.5#abc";
spans[1].strikethrough = false;
event.richValue = spans;}
else event.value = "2.5#abc";
var abn1 = this.getField("Size/Type.0.0.0").value;
if (abn1=="2.5#abc"){
var spans = new Array();
spans[0] = new Object();
spans[1] = new Object();
spans[1].text = "2.5#abc";
spans[1].strikethrough = true;
event.richValue = spans;}
else event.value = "2.5#abc";
var abn1 = this.getField("Size/Type.0.0.0").value;
if (abn1=="5#abc"){
var spans = new Array();
spans[0] = new Object();
spans[1] = new Object();
spans[1].text = "2.5#abc";
spans[1].strikethrough = false;
event.richValue = spans;}
else event.value = "2.5#abc";
...
Continued with the remaining items.
Once I add the next dropdown value, then it only works for the last entered dropdown
...
var abn1 = this.getField("Size/Type.0.0.1").value;
if (abn1==" "){
var spans = new Array();
spans[0] = new Object();
spans[1] = new Object();
spans[1].text = "2.5#abc";
spans[1].strikethrough = false;
event.richValue = spans;}
else event.value = "2.5#abc";
var abn1 = this.getField("Size/Type.0.0.1").value;
if (abn1=="2.5#abc"){
var spans = new Array();
spans[0] = new Object();
spans[1] = new Object();
spans[1].text = "2.5#abc";
spans[1].strikethrough = true;
event.richValue = spans;}
else event.value = "2.5#abc";
At this point, when I select the item from the first dropdown the text no longer strikes out, but it will do so when I select the item from the new dropdown. I need it to work for all of them.
I've attached a sample of my form.
Thank you,
I wrote that in my original description, too. Anyway, you can use this code (as the custom Calculation script of Text2) to achieve it:
var textToFind = "2.5#abc";
var textFound = false;
for (var i=0; i<=27; i++) {
if (this.getField("Size/Type.0.0."+i).value==textToFind) {
textFound = true;
break;
}
}
var spans = new Array();
spans[0] = new Object();
spans[0].text = textToFind;
spans[0].strikethrough = textFound;
event.richValue = spans;
If you want to use the same logic for multiple tex
...Copy link to clipboard
Copied
var abn1 = this.getField("Size/Type.0.0.1").value;
if (abn1=="10# CO2"){
var spans = new Array();
spans[0] = new Object();
spans[1] = new Object();
spans[1].text = "2.5#abc";
spans[1].strikethrough = false;
event.richValue = spans;}
else event.value = "2.5#abc";
The script at the text field will only set the value to "2.5#abc".
The other if clauses makes no sense.
Copy link to clipboard
Copied
Yes. Because the only entry that matters is "2.5#abc" for that text field, so I have it set to "False" on strike through for all the other dropdown options. I would change that for the other text fields.
The problem that I am having is that I will have multiple dropdown boxes, all with the same list of options. I need that any time that option is selected from any of the Drop down Boxes that specific text field gets struck out.
Copy link to clipboard
Copied
Want you display all in one text field?
Copy link to clipboard
Copied
So, to summarize, if any of the Size/Type fields equals "5#abc" then the value of "Text2" should be "2.5#abc" with a strike-through, and if none of them are then it should be "2.5#abc" but without a strike-through?
Copy link to clipboard
Copied
Each item in the dropdown will have its own text box and the item will appear as normal text. Once that item is selected in any of the dropdown boxes, that item is to be replaced in the text box with the strikethrough version to let the user know that that option has already been used.
Copy link to clipboard
Copied
Isn't that the same as what I wrote?
Copy link to clipboard
Copied
Yes, I was just correcting that the Text in the Text 2 box is to remain unstriken unless its matching item is selected from any of the drop-down boxes.
Copy link to clipboard
Copied
I wrote that in my original description, too. Anyway, you can use this code (as the custom Calculation script of Text2) to achieve it:
var textToFind = "2.5#abc";
var textFound = false;
for (var i=0; i<=27; i++) {
if (this.getField("Size/Type.0.0."+i).value==textToFind) {
textFound = true;
break;
}
}
var spans = new Array();
spans[0] = new Object();
spans[0].text = textToFind;
spans[0].strikethrough = textFound;
event.richValue = spans;
If you want to use the same logic for multiple text fields place the code in a doc-level function and pass the textToFind variable to it as a parameter.
Copy link to clipboard
Copied
That was exactly it! And so much more condensed! Thank you for all your help!