Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 5th, 2005, 12:53 AM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default Retrieving unselected items from a select box

Hi All,

Im having some trouble with a function im using.

I have created 2 List boxes on my form

1st Called AvailableCountries
2nd Export

I am using javascript to enable the user to select countries from the 1st list (AvailableCountries) and add it to the 2nd list box (Export).

All works well the only problem is now that i need to retrieve the options in the Export select box when the form has been submitted.

Because the items selected arn't selected like normal eg. <option value="US" selected>US</option>

You can just request.form("Export") because none have been selected.

How can i call in asp the options in the Export Field with ASP?

Thanks

Tim :)

TDA
__________________
TDA
Reply With Quote
  #2 (permalink)  
Old May 5th, 2005, 01:36 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I had the need for a similar thing. It is cut n paste does just what you need it to do:
1..Save the following code to a .asp or .html page
2..Create another page at the same dir level and call it postTo.asp
3..Put this line in the postTo.asp page (the values you need):
<%= request.form("selectedValues") %>

--------------------------start-----------------------
<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
    function moveOver()
    {
    var boxLength = document.choiceForm.choiceBox.length;
    var selectedItem = document.choiceForm.available.selectedIndex;
    var selectedText = document.choiceForm.available.options[selectedItem].text;
    var selectedValue = document.choiceForm.available.options[selectedItem].value;
    var i;
    var isNew = true;
    if (boxLength != 0) {
    for (i = 0; i < boxLength; i++) {
    thisitem = document.choiceForm.choiceBox.options[i].text;
    if (thisitem == selectedText) {
    isNew = false;
    break;
          }
       }
    }
    if (isNew) {
    newoption = new Option(selectedText, selectedValue, false, false);
    document.choiceForm.choiceBox.options[boxLength] = newoption;
    }
    document.choiceForm.available.selectedIndex=-1;
    }
    function removeMe() {
    var boxLength = document.choiceForm.choiceBox.length;
    arrSelected = new Array();
    var count = 0;
    for (i = 0; i < boxLength; i++) {
    if (document.choiceForm.choiceBox.options[i].selected) {
    arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
    }
    count++;
    }
    var x;
    for (i = 0; i < boxLength; i++) {
    for (x = 0; x < arrSelected.length; x++) {
    if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
    document.choiceForm.choiceBox.options[i] = null;
       }
    }
    boxLength = document.choiceForm.choiceBox.length;
       }
    }
    function saveMe() {
    var strValues = "";
    var boxLength = document.choiceForm.choiceBox.length;
    var count = 0;
    if (boxLength != 0) {
    for (i = 0; i < boxLength; i++) {
    if (count == 0) {
    strValues = document.choiceForm.choiceBox.options[i].value;
    }
    else {
    strValues = strValues + "," + document.choiceForm.choiceBox.options[i].value;
    }
    count++;
       }
    }
    if (strValues.length == 0) {
    alert("You have not made any selections");
    }
    else {
    alert("Here are the values you've selected:\r\n" + strValues);
    document.choiceForm.selectedValues.value = strValues;
    choiceForm.submit();
        }
    }

//-->
</script>
</HEAD>
<BODY>
<form name="choiceForm" action="postTo.asp" method="post">
<input type="hidden" name="selectedValues" value="0">
<table border="0">
 <tr>
  <td valign="top" width=175>Available Countries:<br>
  <select name="available" size=10 onchange="moveOver();">
   <option value="1">Australia
   <option value="2">New Zealand
   <option value="3">USA
   <option value="4">Canada
   <option value="5">England
   <option value="6">Switzerland
   <option value="7">Russia
   <option value="8">France
   <option value="9">Italy
   <option value="10">Samoa
  </select></td>
  <td valign="top">Your Choices:<br><select multiple name="choiceBox" style="width:150;" size="10"></select></td>
 </tr>
 <tr>
  <td colspan=2 height=10><input type="button" value="Remove" onclick="removeMe();"><input type="button" value="Alert Then Post My Values" onclick="saveMe();"></td>
 </tr>
</table>
</form>
</body>
</html>

--------------------------finish----------------------

Wind is your friend
Matt
Reply With Quote
  #3 (permalink)  
Old May 5th, 2005, 02:22 AM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default

Thanks Matt

Works like a charm!

Tim :)



TDA
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
Auto Select List Items JpJoe Access VBA 2 November 3rd, 2005 01:12 PM
Retrieving items from a table - Immediate Help badprogrammer Access VBA 2 May 4th, 2005 02:39 PM
Select Items in List from a String mwn1218 Access VBA 1 February 11th, 2005 11:21 AM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM



All times are GMT -4. The time now is 12:10 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.