|
-
Jun 16th, 2003, 06:55 AM
#1
Thread Starter
Retired VBF Adm1nistrator
Selected text in a listbox ?
Okay this is really confusing me now at this stage.
I want to put the selected text from a listbox into a textbox.
I can do everything, except find out what is the selected text.
Any combination I've tried only seems to pull the first item from the listbox...
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jun 16th, 2003, 09:54 AM
#2
Fanatic Member
I whipped this up for you
<html>
<head>
<title>Untitled Document</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getvalue() {
document.form1.text1.value = document.form1.list1.value
}
// End -->
</script>
</head>
<body>
<form name="form1">
<select name="list1" size="1">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<input name="text1" type="text" size="30" onFocus="getvalue();">
</FORM>
</body>
</html>
Last edited by davebat; Jun 16th, 2003 at 10:00 AM.
-
Jun 17th, 2003, 01:19 PM
#3
Code:
<html>
<script>
function test(){
var s = document.frm.sel;
var t1 = document.frm.txt;
var t2 = document.frm.txt2;
t1.value = s.options[s.selectedIndex].text;
t2.value = s.options[s.selectedIndex].value;
}
</script>
<body>
<form name="frm">
<table>
<tr>
<td>Text=</td>
<td><input type="text" name="txt"></td>
</tr>
<tr>
<td>Value=</td>
<td><input type="text" name="txt2"></td>
</tr>
<tr>
<td><select name="sel">
<option value=1>one
<option value=2>two
</select>
</td>
<td><input type="button" onclick="test()" value="selected"></td>
</tr>
</table>
</form>
</body>
</html>
-
Jun 18th, 2003, 01:55 AM
#4
Fanatic Member
-
Jun 18th, 2003, 06:45 AM
#5
Originally posted by DeadEyes
Code:
<html>
<script>
function test(){
var s = document.frm.sel;
var t1 = document.frm.txt;
var t2 = document.frm.txt2;
t1.value = s.options[s.selectedIndex].text;
t2.value = s.options[s.selectedIndex].value;
}
</script>
<body>
<form name="frm">
<table>
<tr>
<td>Text=</td>
<td><input type="text" name="txt"></td>
</tr>
<tr>
<td>Value=</td>
<td><input type="text" name="txt2"></td>
</tr>
<tr>
<td><select name="sel">
<option value=1>one
<option value=2>two
</select>
</td>
<td><input type="button" onclick="test()" value="selected"></td>
</tr>
</table>
</form>
</body>
</html>
How about closing them option tags? Or quite a few other issues.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 18th, 2003, 06:58 AM
#6
Fanatic Member
no wonder your finally custom if you respond to every single post on this forum
-
Jun 18th, 2003, 10:06 AM
#7
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 18th, 2003, 02:15 PM
#8
Originally posted by CornedBee
How about closing them option tags? Or quite a few other issues.
I normally would, it's one thing XML's got me doing, but it's just a harness.
I have my editor to load new files like that so I can throw functions together quickly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|