Results 1 to 2 of 2

Thread: Text Box

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Text Box

    Hi,

    I have a text box and a drop down menu. Now the text box is blank so a user and write their own information in it. but the drop down box has a heap of answers already in it. when a user selects one of the options in the drop down box it will transfer the info to the text box... does anyone know how this would work??

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    The following HTML does this. It uses the onchange event of the option select box and a javascript function.

    I posted it on my website if you want to see it working:

    http://adam.codedv.com/textbox.html

    Code:
    <!DOCTYPE html 
         PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<title>Textbox Transfer</title>
    		<script type="text/javascript">
    			<!--
    			function processchange ()
    			{
    				var theForm = document.getElementById('questions');
    
    				theForm.answertext.value = theForm.answers.value;
    			}
    			//-->
    		</script>
    	</head>
    	<body>
    		<form action="submit.php" id="questions">
    		<p>
    			<input type="text" name="answertext" />
    			<select name="answers" onchange="processchange();">
    				<option>answer1</option>
    				<option>answer2</option>
    				<option>answer3</option>
    			</select>
    		</p>
    		</form>		
    	</body>
    </html>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width