Ok, I have a form with three buttons Add unit #, Remove unit #and then update unit #.
The user types the unit number in and adds it to the select option list.
User can delete or remove the number if need be.
At the end of it all, the form will be checking to see if the unit number exist in the DB table i have created. If it does, then update the status.
My problem is, how do i compare the select option values entered by the user to the already existing ones in the table.
I get i need a loop but i can figure out how to get the values from the select option box with ASP.
Here is the Code
<script language="javascript" type="text/javascript">
//Adding Unit number to list to be checked
function myFunction()
{
var y = document.getElementById("input");
var x = document.getElementById("mySelect");
var option = document.createElement("option");
if((/^[0-9]+$/gm.test(y.value)))
{
option.text = y.value;
x.add(option);
}else{
alert('You must enter a unit number with now spaces.');
}
}
//Delete Selected units or all at once
function myDelete(selectbox)
{
var i;
for(i=selectbox.options.length-1; i>=0; i--)
{
if (selectbox.options.selected)
selectbox.remove(i);
}
}
</script>
<form id="myForm" name="myForm" method="post" action="default.asp">
<table id='tabBut' border="0">
<tr>
<td colspan="2"><div style="font-size:12px; color:#343398; font-weight: bold;">Unit Number To Add To List</div></td>
</tr>
<tr>
<td>
<input type="text" id="input" name="input" size="40" required/>
</td>
<td>
<button type="button" onClick="myFunction();">Add Unit</button>
</td>
</tr>
<tr>
<td colspan="2"><div style="font-size:12px; color:#343398; font-weight: bold;">Units Numbers To Update Status</div>
</td>
</tr>
<tr>
<td>
<select id="mySelect" name="box" multiple size="15"></select>
</td>
<td valign="top">
<button type="button" onClick="myDelete(mySelect);">Remove Unit</button>
</td>
</tr>
<tr>
</tr>
<td><div style="font-size:12px; color:#343398; font-weight: bold;">Status To Update</div></td>
<tr>
<td>
<select class="colorbg" style="width: 240px">
<option>Quick Pics</option>
<option>Photographed</option>
<option>Tile Ready For Auction</option>
</select>
</td>
<td><button type="button" name="CheckNums" >Update Unit</button></td>
</tr>
</table>
</form>
The user types the unit number in and adds it to the select option list.
User can delete or remove the number if need be.
At the end of it all, the form will be checking to see if the unit number exist in the DB table i have created. If it does, then update the status.
My problem is, how do i compare the select option values entered by the user to the already existing ones in the table.
I get i need a loop but i can figure out how to get the values from the select option box with ASP.
Here is the Code
<script language="javascript" type="text/javascript">
//Adding Unit number to list to be checked
function myFunction()
{
var y = document.getElementById("input");
var x = document.getElementById("mySelect");
var option = document.createElement("option");
if((/^[0-9]+$/gm.test(y.value)))
{
option.text = y.value;
x.add(option);
}else{
alert('You must enter a unit number with now spaces.');
}
}
//Delete Selected units or all at once
function myDelete(selectbox)
{
var i;
for(i=selectbox.options.length-1; i>=0; i--)
{
if (selectbox.options.selected)
selectbox.remove(i);
}
}
</script>
<form id="myForm" name="myForm" method="post" action="default.asp">
<table id='tabBut' border="0">
<tr>
<td colspan="2"><div style="font-size:12px; color:#343398; font-weight: bold;">Unit Number To Add To List</div></td>
</tr>
<tr>
<td>
<input type="text" id="input" name="input" size="40" required/>
</td>
<td>
<button type="button" onClick="myFunction();">Add Unit</button>
</td>
</tr>
<tr>
<td colspan="2"><div style="font-size:12px; color:#343398; font-weight: bold;">Units Numbers To Update Status</div>
</td>
</tr>
<tr>
<td>
<select id="mySelect" name="box" multiple size="15"></select>
</td>
<td valign="top">
<button type="button" onClick="myDelete(mySelect);">Remove Unit</button>
</td>
</tr>
<tr>
</tr>
<td><div style="font-size:12px; color:#343398; font-weight: bold;">Status To Update</div></td>
<tr>
<td>
<select class="colorbg" style="width: 240px">
<option>Quick Pics</option>
<option>Photographed</option>
<option>Tile Ready For Auction</option>
</select>
</td>
<td><button type="button" name="CheckNums" >Update Unit</button></td>
</tr>
</table>
</form>