Solved

Adding a selected value from a listbox to a form.

Posted on 2002-03-08
4
325 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…

791 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