I'm sure my error here is simple
I have a 2d Array from my sqlDB on a single column
myList = rs.GetRows()
I have html page with inputs based on the length of my array. :
<input type="number" name="actual">
now, what I'm trying to do is build a unique SQL update query where the actual column matches the unique_id column
lets assume we have only two variables on my list.
for each x in my list
response.write(x)
1,
2
and there are only two inputs as the inputs are generated by the unique ID
for inputs in response.form("actual")
response.write(inputs)
55,
66
now, I want to combine these to build my update query.
I've tried writing a double for loop but this generates an ID for every instance of the input so creating 4 variables instead of 2
Unique ID, Input
1 : 55
1 : 66
2 : 55
2 : 66
what I would like is
1 : 55
2 : 66
is anyone able to help? I've been at this for hours. I'm not a coder or from a technical background and I'm knee deep in legacy systems and processes.
I'm sure a dictionary would be the way to go so I can generated a 1 for 1 relationship but I have no idea how to convert my inputs into a list then pass them into a dict.
html code to generate my table :
<div class="container">
<table id="table" class="table">
<thead class="thead-dark">
<tr>
<th scope="col" data-field="article">Unique ID</th>
<th scope="col" data-field="item">Item Name</th>
<th scope="col" data-field="quant">Quantity</th>
<th scope="col" data-field="act">Actual</th>
</tr>
</tr>
</thead>
</div>
<%
While not grs.eof
%>
<tr>
<th><%=grs.fields("UniqueID")%></th>
<th><%=grs.fields("itemName")%></th>
<th><%=grs.fields("quant")%></th>
<input type="number" class="form-control" id="actual" placeholder="<%=grs.fields("actual")%>" name="Actual">
<%
grs.movenext
Wend
SQL update query goes here %>
Ok, little thing here:
Your id can't be the same for every line, so do something like id=actual_<%=grs.fields("UniqueID")%>
You can try this:
<input type="number" class="form-control" id="actual_<%=grs.fields("UniqueID")%>" placeholder="<%=grs.fields("actual")%>" name="actual_<%=grs.fields("UniqueID")%>">
And then in your loop:
for each inputs in request.form
if left(inputs, 7) = "actual_" then
myId = mid(inputs, 8)
myValue = request.form("actual_" & myId)
<your sql statement here>
end if
next
(You'll have to add something to check the name of the input you're checking is at least 7 chars long or you'll get an error)