Solved

Adding a selected value from a listbox to a form.

Posted on 2002-03-08
4
316 Views
Last Modified: 2013-12-23
How do I add a value that I click on in a listbox (created in HTML) to a textbox in a form (<FORM></FORM>).

The listbox is not in the <FORM></FORM> tags.

How?????

Thanks

Hannes

0
Comment
Question by:hannes1
  • 3
4 Comments
 
LVL 4

Expert Comment

by:vindevogel
ID: 6850566
    <html>
          <head>
               <script language=vbscript>
                    sub SetTextbox
                         window.document.forms(0).txtBox.value = select1.options( select1.selectedIndex ).text
                    end sub
               </script>
          </head>
         
          <body>
               <form>
                    <input type=text id=txtBox>
               </form>
               
               <SELECT size=2 id=select1 name=select1 onclick="SetTextBox">
                    <OPTION>Possibility1</OPTION>
                    <OPTION>Possibility2</OPTION>
               </SELECT>
          </body>
     </html>


This page might help you.
0
 
LVL 4

Accepted Solution

by:
vindevogel earned 20 total points
ID: 6850574
Or with Javascript, in case Webwoman sees this question, and says VBScript is for the kids.

<script language=javascript>
function SetTextbox()
{     window.document.forms(0).txtBox.value = select1.options(select1.selectedIndex).text;
}
</script>
0
 

Author Comment

by:hannes1
ID: 6855876
I aplogise for taking so long.

Thanks

Hannes
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6855906
No problem, thanks for the points
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now