navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

drop down box

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> drop down box
Page: [1]
 
kitty6

 

Posts: 150
Joined: 10/15/2005
Status: offline

 
drop down box - 8/17/2008 21:30:14   
I have a dropdown box and would like to have a textbox equal a value based on the value in the dropdown. I'm using the following code but it does nothing. Can someone tell me what I'm doing wrong? Thanks.

The form name is TS.


<script>function updateTextBox(val)
{
if(val == "aaa")
{
document.forms['TS'].elements['State'].value = "Test";
}
else if(val == "ccc")
{
document.forms['TS'].elements['State'].value = "Test2";
}
}
</script>


<select onchange='updateTextBox(this.value)' name="TSCodeBox" size="1">
<option selected>Select</option>
<option>aaa</option>
<option>ccc</option>
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: drop down box - 8/17/2008 22:22:50   
quote:

document.forms['TS'].elements['State'].value = "Test";


This way work any better?

document.getElementById("State").value = 'Test';

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to kitty6)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: drop down box - 8/17/2008 22:31:57   
Oh wait. Ooops, there was a lot more that I should have seen. The selection of the dropdown box as the biggie. What you need is a little JS to figure out which option is selected.

I'd try it something like so:

...
if(document.TS.TSCodeBox.options[document.TS.TSCodeBox.selectedIndex].value == 'aaa')
{
document.getElementById("State").value = 'Test';
} else {
...

but you must give your text box an id="State" as well a name="State" tag. Well, you really don't need the "name" tag but to use getElementById you need an "id" tag to get.

Make sense? That help any?





_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to rdouglass)
kitty6

 

Posts: 150
Joined: 10/15/2005
Status: offline

 
RE: drop down box - 8/18/2008 10:15:09   
Still nothing? When I select the aaa nothing changes in the text box.

(in reply to rdouglass)
kitty6

 

Posts: 150
Joined: 10/15/2005
Status: offline

 
RE: drop down box - 8/18/2008 10:23:34   
Here is the url where I got the orginal code:

http://www.tek-tips.com/viewthread.cfm?qid=1213621&page=1

I created a page from that code and can't get it to work?

Maybe you can? Thanks.

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: drop down box - 8/18/2008 10:29:54   
quote:

I created a page from that code and can't get it to work?


Do you have a URL for that page you're creating? It could be something else entirely and I'd just like to double check.

I say that because I use that code in a lot of places; maybe not in that exact specific way but that's fairly standard JS stuff being used everywhere and it'll be easier for me if I have a specific page to look at.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to kitty6)
kitty6

 

Posts: 150
Joined: 10/15/2005
Status: offline

 
RE: drop down box - 8/18/2008 12:33:34   
http://www.labonlocale.com/TS/dropdown.htm

I must be doing something wrong. Thanks for your help!

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: drop down box - 8/18/2008 13:47:37   
Here is my version of that page:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<script>function updateTextBox(val)
{
 if(val == "something")
 {
  document.getElementById("myTextBox").value = "something based on something";
 }
 else if(val == "something else")
 {
  document.getElementById("myTextBox").value = "something based on something else";
 }  else if(val == "aaa")
 {
  document.getElementById("myTextBox").value = "something based on aaa";
 }
 
}
</script>
</head>

<body>

<form method="POST" action="--WEBBOT-SELF--" name="myform" id="myform">
    <!--webbot bot="SaveResults" startspan U-File="../_private/form_results.csv"
    S-Format="TEXT/CSV" S-Label-Fields="TRUE" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot
    bot="SaveResults" endspan -->
	<p>
<select size="1" name="D1" onchange='updateTextBox(this.value)'>
<option selected>aaa</option>
<option value="something">something</option>
<option value="something else">Something else</option>
</select></p>
	<p> </p>
	<p><input type="text" name="myTextBox" id="myTextBox" size="50"></p>
	<p> </p>
	<p> </p>
	<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>

</html>


That domain looks quit familiar to me.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to kitty6)
kitty6

 

Posts: 150
Joined: 10/15/2005
Status: offline

 
RE: drop down box - 8/19/2008 10:06:55   
Thanks! I see where I went wrong. I did not have any values in for the drop down entries.

Thanks again!!!

(in reply to rdouglass)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> drop down box
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts