INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Select option compare user input

Select option compare user input

(OP)
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[i].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>

RE: Select option compare user input

Quote:

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: Javascript

Chris.

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

RE: Select option compare user input

(OP)
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

RE: Select option compare user input

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close