'How to display data to multiple text box field (more than 100) based on combo box selection in PDF by using JavaScript
I have declared my arrays in a combo box and wants to show the data to different textbox based on combo box selection. Tried the most time consuming method and the sample below. It is working perfectly fine.
VAR fruits = ['Item | Apple | 10.0',]; //declared array
var Textbox_0 = this.getField("Textbox_0").value;
var combobox1 = this.getField("combobox1").value;
if (combobox1 == "fruits") { this.getField("Textbox_0").value = fruits[0]} else { this.getField("Textbox_0").value = "Nothing"}
My questions are. 1.Is there any way to use 1 text box and change to multiline to show all the data. Instead of creating multiple text fields? OR 2.Is there any way to define the range of textbox fields to display the data. Instead of defining one by one? example fill the data from Textbox 1 to 100 3.How to use the for loop for this? Tried with for loop but it is displaying only the last value of the array not all of them? Please help on this issue!
Solution 1:[1]
You can try:
with open('data.DAT') as inp:
out = None
for line in inp:
if line.startswith('TRACE'):
if out != None:
out.close()
filename = f"Trace{line.split()[1][:-1]}.DAT"
out = open(filename, 'w')
else:
out.write(line)
out.close()
Solution 2:[2]
a bit lengthy but works :)
with open('data.DAT', 'r') as filereader:
read = filereader.readlines()
traceOne = None
TraceTwo = None
TraceThree = None
for i in read:
if i.startswith("TRACE:1"):
traceOne = read.index(i)
elif i.startswith("TRACE 2:"):
TraceTwo = read.index(i)
elif i.startswith("TRACE 3:"):
TraceThree = read.index(i)
else:
continue
with open('TRACE1.DAT', 'w+') as writeTraceONE:
traceonefile = writeTraceONE.writelines("\n".join(read[traceOne:TraceTwo]))
with open('TRACE2.DAT', 'w+') as writeTraceTwo:
tracetwofile = writeTraceTwo.writelines("\n".join(read[TraceTwo:TraceThree]))
with open('TRACE3.DAT', 'w+') as writeTraceThree:
traceThreeFile = writeTraceThree.writelines("\n".join(read[TraceThree:]))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | salem |
