Я работаю над проектом Classic ASP, где я обновляю несколько записей в таблице с помощью одной кнопки Отправить.Каждая строка имеет поле выбора и текстовое поле, и пользователь может обновить все строки.При отправке параметров в хранимую процедуру я хочу передать только те значения, в которых были изменены входные значения (поле выбора или текстовое поле).Я не могу понять, как мне это сделать.sCycleTime (Id) и sComment (id) содержат значения Select Box и Textbox всех строк.sProfile (id) и sProcess_Step_Sequence (Id) - это два идентификатора, связанные в каждом поле выбора и текстовом поле.Например: DrpDwn_1_4, Txtbox_1_4 и т. Д. ... Ссылка на шаблон: https://drive.google.com/drive/folders/1MrBxo89vvedMbt1pSYzvbLUFhGfU6ocL?usp=sharing
Редактировать: я не ищу способ передачи параметра в хранимую процедуру.Увидеть мое требование было обновить несколько записей одновременно, нажав кнопку Отправить.Поэтому при нажатии кнопки «Отправить» у меня есть функция JavaScript, которая используется для установки значения формы, действия, метода, а затем «Отправить».В ASP у меня есть цикл «для каждого», который получает значения всех текстовых полей и блоков выбора.затем добавляем эти значения в строку, разделенную специальными символами, и, наконец, читаем их в базе данных.Все работает нормально, но я хочу отправить только те строки для обновления, где значения в тексте и поле выбора изменились -
Источник HTML:
<html>
<head>
<title> Dashboard:</title>
<script language="JavaScript">
var gAutoPrint = true; // Tells whether to automatically call the print function
function printSpecial()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n';
if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}
html += '\n</HE>\n<BODY>\n';
var printReadyElem = document.getElementById("printReady");
if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady function");
return;
}
html += '\n</BO>\n</HT>';
var printWin = window.open("","printSpecial");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint)
printWin.print();
}
else
{
alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
}
}
function validate()
{
//alert('here');
var elements = document.getElementById("frmDtls").elements ;
var val = [] ;
var flag = true;
var x = -1;
var y = 0;
if(flag == true)
{
document.frmDtls.hfrom.value = 'Updt' ;
document.frmDtls.method = "post" ;
document.frmDtls.action = "samepage.asp" ;
document.frmDtls.submit();
// alert("Record has been Updated Successfully!");
//window.location.href = window.location.href;
// location.reload();
}
// alert(flag);
}
</script>
</head>
<body background="Images/Notebook.jpg">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td width="100%" align="center">
<img border="0" src="Axalta Coating Systems Logo.jpg" width="1200" height="60"></td>
</tr>
</table>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" bgcolor="#C0C0C0" align="center"><b>
<font face="Times New Roman" size="4"> CYCLE TIMES and UNITS for UPDATING </font></b>
</TD>
</tr>
</table>
<div id="printReady">
<div align="center" id="formdiv"><center>
<form id="frmDtls" name="frmDtls">
<!--<form id="frmDtls" name="frmDtls" target="MyFrame">-->
<iframe id="MyFrame" name="MyFrame" style="display:none;"></iframe>
<input type="hidden" name="hfrom" value = "">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="70%" bgcolor="#C0C0C0" align="center"><b>
<font face="Times New Roman" size="5">SELECTED DUAL CODE DETAILS </font></b> </td>
<td width="13%" align="Middle" valign = "Middle" bgcolor="#FFFF00">
<input type="button" name='update' value = 'Update' onclick='validate();'>
</TD>
<td width="17%" bgcolor="#C0C0C0" align="Center">
<b><font face="Times New Roman" size="2">
LATEST POSTING DATE / TIME 2/13/2019 7:09:20 AM</font></b>
</TD>
</tr>
</table>
<table BORDER="1" CELLSPACING="1" CELLPADDING="1"
style="font-weight: normal; letter-spacing: normal; text-align: left; width:100%;">
<tr align="center">
<th><small><small><span style="color:darkgreen;font-weight:bold">Profile ID</small></small></th>
<th><WIDTH="200"><small><small><span style="color:green;font-weight:bold">DUAL CODE</small></small></th>
<th><small><span style="color:darkgreen;font-weight:bold">Description</small></th>
<th><small><span style="color:darkgreen;font-weight:bold">R/D Material?</small></th>
<th><small><small><span style="color:darkgreen;font-weight:bold">Process Step Name</small></small></th>
<th><small><small><span style="color:darkgreen;font-weight:bold">Process Step Sequence</small></small></th>
<th><small><small><span style="color:darkgreen;font-weight:bold">FROM Event Status</small></small></th>
<th><small><small><span style="color:darkgreen;font-weight:bold">TO Event Status</small></small></th>
<th><small><small><span style="color:darkblue;font-weight:bold">Current CYCLE TIME</small></small></th>
<th><small><small><span style="color:darkred;font-weight:bold">Updated CYCLE TIME</small></small></th>
<th><small><small><span style="color:darkblue;font-weight:bold">Cycle Time Units</small></small></th>
<th><small><small><span style="color:darkred;font-weight:bold">Updated Units</small></small></th>
<th><small><small><span style="color:darkblue;font-weight:bold">Comments</small></small></th>
</tr>
<tr>
<td><input type="Hidden" name="l_enteredpartialdualcode" value="" > </td>
<td><input type="Hidden" name="l_selecteddualcodes" value="1026-FD195, 1143-01427" > </td>
<td><input type="Hidden" name="l_selectedprocessstepnames" value="" > </td>
<td><input type="Hidden" name="l_selectedgbtindicato" value="Both" > </td>
<td><input type="Hidden" name="l_multipledualcodess" value="" > </td>
</tr>
<TR align=center><TD Width=90 Height=3 nowrap ><B>1</B></TD><TD Width=90 Height=3 nowrap ><B>1026-FD195</B></TD><TD WIDTH=200 Height=3><small><small><B>1026-FD195 E500546 DARK GRAY WBPR</B></small></small></TD><TD WIDTH=30 Height=3><small><small><B></B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>Load_Cycle</B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>2</B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>LDGS </B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>LDGC </B></small></small></TD><TD WIDTH=70 Height=3><B>6</B></TD><TD WIDTH=70 Height=3><small><small><B><Select name = 'DDSQ_1_2' font-size=1><option value = '1' >1</option><option value = '2' >2</option><option value = '3' >3</option><option value = '4' >4</option><option value = '5' >5</option><option value = '6' selected>6</option><option value = '7' >7</option><option value = '8' >8</option><option value = '9' >9</option><option value = '10' >10</option><option value = '11' >11</option><option value = '12' >12</option><option value = '13' >13</option><option value = '14' >14</option><option value = '15' >15</option><option value = '16' >16</option><option value = '17' >17</option><option value = '18' >18</option><option value = '19' >19</option><option value = '20' >20</option><option value = '21' >21</option><option value = '22' >22</option><option value = '23' >23</option><option value = '24' >24</option><option value = '-1' >Clear</option></Select></B></small></small></TD>
<TD WIDTH=70 Height=3 nowrap><small><small><B>
Hours </B></small></small></TD><TD WIDTH=70 Height=3><small><small><B></B></small></small></TD>
<td WIDTH=100 Height=3><small><small><B><input type="text" name="txt_1_2" value="test1" >
</B></small></small></TD>
<TR align=center><TD Width=90 Height=3 nowrap ><B>1</B></TD><TD Width=90 Height=3 nowrap ><B>1026-FD195</B></TD><TD WIDTH=200 Height=3><small><small><B>1026-FD195 E500546 DARK GRAY WBPR</B></small></small></TD><TD WIDTH=30 Height=3><small><small><B></B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>Test_Cycle</B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>4</B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>TSTS </B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>TSTC </B></small></small></TD><TD WIDTH=70 Height=3><B>6</B></TD><TD WIDTH=70 Height=3><small><small><B><Select name = 'DDSQ_1_4' font-size=1><option value = '1' >1</option><option value = '2' >2</option><option value = '3' >3</option><option value = '4' >4</option><option value = '5' >5</option><option value = '6' selected>6</option><option value = '7' >7</option><option value = '8' >8</option><option value = '9' >9</option><option value = '10' >10</option><option value = '11' >11</option><option value = '12' >12</option><option value = '13' >13</option><option value = '14' >14</option><option value = '15' >15</option><option value = '16' >16</option><option value = '17' >17</option><option value = '18' >18</option><option value = '19' >19</option><option value = '20' >20</option><option value = '21' >21</option><option value = '22' >22</option><option value = '23' >23</option><option value = '24' >24</option><option value = '-1' >Clear</option></Select></B></small></small></TD>
<TD WIDTH=70 Height=3 nowrap><small><small><B>
Hours </B></small></small></TD><TD WIDTH=70 Height=3><small><small><B></B></small></small></TD>
<td WIDTH=100 Height=3><small><small><B><input type="text" name="txt_1_4" value="" >
</B></small></small></TD>
<TR align=center><TD Width=90 Height=3 nowrap ><B>1</B></TD><TD Width=90 Height=3 nowrap ><B>1026-FD195</B></TD><TD WIDTH=200 Height=3><small><small><B>1026-FD195 E500546 DARK GRAY WBPR</B></small></small></TD><TD WIDTH=30 Height=3><small><small><B></B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>FILL_Cycle</B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>6</B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>FLGS </B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>FLGC </B></small></small></TD><TD WIDTH=70 Height=3><B>4</B></TD><TD WIDTH=70 Height=3><small><small><B><Select name = 'DDSQ_1_6' font-size=1><option value = '1' >1</option><option value = '2' >2</option><option value = '3' >3</option><option value = '4' selected>4</option><option value = '5' >5</option><option value = '6' >6</option><option value = '7' >7</option><option value = '8' >8</option><option value = '9' >9</option><option value = '10' >10</option><option value = '11' >11</option><option value = '12' >12</option><option value = '13' >13</option><option value = '14' >14</option><option value = '15' >15</option><option value = '16' >16</option><option value = '17' >17</option><option value = '18' >18</option><option value = '19' >19</option><option value = '20' >20</option><option value = '21' >21</option><option value = '22' >22</option><option value = '23' >23</option><option value = '24' >24</option><option value = '-1' >Clear</option></Select></B></small></small></TD>
<TD WIDTH=70 Height=3 nowrap><small><small><B>
Hours </B></small></small></TD><TD WIDTH=70 Height=3><small><small><B></B></small></small></TD>
<td WIDTH=100 Height=3><small><small><B><input type="text" name="txt_1_6" value="test1" >
</B></small></small></TD>
<TR align=center><TD Width=90 Height=3 nowrap ><B>2</B></TD><TD Width=90 Height=3 nowrap ><B>1143-01427</B></TD><TD WIDTH=200 Height=3><small><small><B>1143-01427 E450552 TITANIUM SBPR</B></small></small></TD><TD WIDTH=30 Height=3><small><small><B></B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>Load_Cycle</B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>2</B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>LDGS </B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>LDGC </B></small></small></TD><TD WIDTH=70 Height=3><B>3</B></TD><TD WIDTH=70 Height=3><small><small><B><Select name = 'DDSQ_2_2' font-size=1><option value = '1' >1</option><option value = '2' >2</option><option value = '3' selected>3</option><option value = '4' >4</option><option value = '5' >5</option><option value = '6' >6</option><option value = '7' >7</option><option value = '8' >8</option><option value = '9' >9</option><option value = '10' >10</option><option value = '11' >11</option><option value = '12' >12</option><option value = '13' >13</option><option value = '14' >14</option><option value = '15' >15</option><option value = '16' >16</option><option value = '17' >17</option><option value = '18' >18</option><option value = '19' >19</option><option value = '20' >20</option><option value = '21' >21</option><option value = '22' >22</option><option value = '23' >23</option><option value = '24' >24</option><option value = '-1' >Clear</option></Select></B></small></small></TD>
<TD WIDTH=70 Height=3 nowrap><small><small><B>
Hours </B></small></small></TD><TD WIDTH=70 Height=3><small><small><B></B></small></small></TD>
<td WIDTH=100 Height=3><small><small><B><input type="text" name="txt_2_2" value="" >
</B></small></small></TD>
<TR align=center><TD Width=90 Height=3 nowrap ><B>2</B></TD><TD Width=90 Height=3 nowrap ><B>1143-01427</B></TD><TD WIDTH=200 Height=3><small><small><B>1143-01427 E450552 TITANIUM SBPR</B></small></small></TD><TD WIDTH=30 Height=3><small><small><B></B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>Test_Cycle</B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>4</B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>TSTS </B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>TSTC </B></small></small></TD><TD WIDTH=70 Height=3><B>6</B></TD><TD WIDTH=70 Height=3><small><small><B><Select name = 'DDSQ_2_4' font-size=1><option value = '1' >1</option><option value = '2' >2</option><option value = '3' >3</option><option value = '4' >4</option><option value = '5' >5</option><option value = '6' selected>6</option><option value = '7' >7</option><option value = '8' >8</option><option value = '9' >9</option><option value = '10' >10</option><option value = '11' >11</option><option value = '12' >12</option><option value = '13' >13</option><option value = '14' >14</option><option value = '15' >15</option><option value = '16' >16</option><option value = '17' >17</option><option value = '18' >18</option><option value = '19' >19</option><option value = '20' >20</option><option value = '21' >21</option><option value = '22' >22</option><option value = '23' >23</option><option value = '24' >24</option><option value = '-1' >Clear</option></Select></B></small></small></TD>
<TD WIDTH=70 Height=3 nowrap><small><small><B>
Hours </B></small></small></TD><TD WIDTH=70 Height=3><small><small><B></B></small></small></TD>
<td WIDTH=100 Height=3><small><small><B><input type="text" name="txt_2_4" value="test" >
</B></small></small></TD>
<TR align=center><TD Width=90 Height=3 nowrap ><B>2</B></TD><TD Width=90 Height=3 nowrap ><B>1143-01427</B></TD><TD WIDTH=200 Height=3><small><small><B>1143-01427 E450552 TITANIUM SBPR</B></small></small></TD><TD WIDTH=30 Height=3><small><small><B></B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>FILL_Cycle</B></small></small></TD><TD WIDTH=100 Height=3><small><small><B>6</B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>FLGS </B></small></small></TD><TD WIDTH=90 Height=3><small><small><B>FLGC </B></small></small></TD><TD WIDTH=70 Height=3><B>6</B></TD><TD WIDTH=70 Height=3><small><small><B><Select name = 'DDSQ_2_6' font-size=1><option value = '1' >1</option><option value = '2' >2</option><option value = '3' >3</option><option value = '4' >4</option><option value = '5' >5</option><option value = '6' selected>6</option><option value = '7' >7</option><option value = '8' >8</option><option value = '9' >9</option><option value = '10' >10</option><option value = '11' >11</option><option value = '12' >12</option><option value = '13' >13</option><option value = '14' >14</option><option value = '15' >15</option><option value = '16' >16</option><option value = '17' >17</option><option value = '18' >18</option><option value = '19' >19</option><option value = '20' >20</option><option value = '21' >21</option><option value = '22' >22</option><option value = '23' >23</option><option value = '24' >24</option><option value = '-1' >Clear</option></Select></B></small></small></TD>
<TD WIDTH=70 Height=3 nowrap><small><small><B>
Hours </B></small></small></TD><TD WIDTH=70 Height=3><small><small><B></B></small></small></TD>
<td WIDTH=100 Height=3><small><small><B><input type="text" name="txt_2_6" value="test2" >
</B></small></small></TD>
</table>
</form>
</center>
</div>
</div>
<p><small><small><strong>
End of Report.</strong></small></small></p>
<p align="center"><strong><big><big> </big></big></strong></p>
</body>
</html>
document.frmDtls.hfrom.value = 'Updt' ;
document.frmDtls.method = "post" ;
document.frmDtls.action = "PRDB_Display_Selected_DUAL_CODE_CYCLE_TIMES_for_UPDATES.asp" ;
document.frmDtls.submit();
sQry = ""
For Id = 0 to 22
response.Write ("this is " & l_comments)
If Trim(sProcess_Step_Sequence (Id)) <> "" Then
If Trim(sQry) = "" Then
sQry = sProfile(id) & "~" & sCycleTime(Id) & "`" & sProcess_Step_Sequence(Id) & "^" & sComment(id)
Else
sQry = sQry & "!" & sProfile(id) & "~" & sCycleTime(Id) & "`" & sProcess_Step_Sequence(Id)& "^" & sComment(id)
End If
End If
Next
objCommand.CommandText = "EXEC usp_UPDATE_Dual_Code_Cycle_Times_and_Comments '" & sQry & "' ; "