Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select option compare user input

Status
Not open for further replies.

Whiskypoo

Programmer
Apr 12, 2016
2
US
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>
 
I get i need a loop but i can figure out how to get the values from the select option box with ASP.

With ASP Code???


You can't.

forum216

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
So far Im able to pull the values and display them with a for loop
I put in a select statement at the top so it reloads the page and runs a different function with the selected values.

Dim Test
set Test = Request("lstUnitNums")
For a = 1 to Test.Count
Response.Write("The Unit " & Test(a) & " was selected<BR>")
Next

 
NEVER going to work.


ASP code runs BEFORE the user even gets to SEE the page

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top