Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Get Value of List Box In a Function


Message #1 by "Rita Greenberg" <rg1@h...> on Thu, 29 Mar 2001 01:00:14
Hi.



I have a drop down list box. When the user makes a selection, I have 

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list 

box1. 



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px' 

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions()  

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita
Message #2 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Thu, 29 Mar 2001 13:22:57 +0100
Just pass the value into the function using "this"



<SELECT onchange='getversions(this.value)'>



<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions(sPPO)

{  	

 	//... do whatever with sPPO

}	

</script>





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 2:00 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have 

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list 

box1. 



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px' 

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions()  

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita

Message #3 by "Peter Lanoie" <planoie@e...> on Thu, 29 Mar 2001 09:10:13 -0500
Rita,



In your HTML, the form name is AddGroup (big G) but your javascript call to

it is a little g.

That get's me every time too! :)



Peter





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Wednesday, March 28, 2001 8:00 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list

box1.



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px'

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID

*/

function getversions()

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita

Message #4 by Rita Greenberg <rg1@h...> on Thu, 29 Mar 2001 07:37:34 -0800
Hi Peter.



Yup, that was a problem! However, when I made the change, it never returned

the value of what I had selected in the drop down list box. It's driving me

nuts! (:-P) It should work but is not. Any suggestions?



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Thursday, March 29, 2001 6:10 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



In your HTML, the form name is AddGroup (big G) but your javascript call to

it is a little g.

That get's me every time too! :)



Peter





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Wednesday, March 28, 2001 8:00 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list

box1.



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px'

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID

*/

function getversions()

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita

Message #5 by Rita Greenberg <rg1@h...> on Thu, 29 Mar 2001 07:54:44 -0800
Hi Alex.



Thanks for this "simple" solution. However, when I tried it with my code I

got the value returned as nothing. What's interesting is that I create the

drop down list box dynamically from a record set. Just for the heck of it, I

added a regular drop down list box and "this.value" worked fine with that

one!



Here's my code for creating the dynamic list box:

  <%	

  'Populate drop down list box with recordset of Build PPO Network IDs 

  Dim sHold						'Don't populate

duplicate PPONetworkIDs

  

  oComm.CommandType = adCmdStoredProc



  oComm.CommandText = "rBUILDSSelAllProc"	'Stored Procedure name

  Set oRS = oComm.Execute()			'Return Builds

  

  sListBox = "<select id='oPPONetworkID' name='oPPONetworkID' style='width:

60px' onchange='getversions(this.value)'>" & vbCRLF

  Set sName = oRS.Fields("PPONetworkID")	'Build list box with

PPONetwork ID's

  

  Do Until oRS.EOF 

	If sHold <> sName Then			'Check for duplicate

PPONetworkIDs

		sListBox = sListBox & "<option>" & sName & "</option>" &

vbCRLF

		sHold = sName

	End If

	oRS.MoveNext

  Loop 



  sListBox = sListBox & "</select>" & vbCRLF



  Response.Write ("<td>" & slistBox & "</td>")

  %>  



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: Thursday, March 29, 2001 4:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Just pass the value into the function using "this"



<SELECT onchange='getversions(this.value)'>



<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions(sPPO)

{  	

 	//... do whatever with sPPO

}	

</script>





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 2:00 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have 

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list 

box1. 



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px' 

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions()  

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita

Message #6 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Fri, 30 Mar 2001 10:36:44 +0100
Try replacing



sListBox = sListBox & "<option>" & sName & "</option>" 



with



sListBox = sListBox & "<option value=""" & sName & """>" & sName &

"</option>" &



-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 4:55 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Alex.



Thanks for this "simple" solution. However, when I tried it with my code I

got the value returned as nothing. What's interesting is that I create the

drop down list box dynamically from a record set. Just for the heck of it, I

added a regular drop down list box and "this.value" worked fine with that

one!



Here's my code for creating the dynamic list box:

  <%	

  'Populate drop down list box with recordset of Build PPO Network IDs 

  Dim sHold						'Don't populate

duplicate PPONetworkIDs

  

  oComm.CommandType = adCmdStoredProc



  oComm.CommandText = "rBUILDSSelAllProc"	'Stored Procedure name

  Set oRS = oComm.Execute()			'Return Builds

  

  sListBox = "<select id='oPPONetworkID' name='oPPONetworkID' style='width:

60px' onchange='getversions(this.value)'>" & vbCRLF

  Set sName = oRS.Fields("PPONetworkID")	'Build list box with

PPONetwork ID's

  

  Do Until oRS.EOF 

	If sHold <> sName Then			'Check for duplicate

PPONetworkIDs

		sListBox = sListBox & "<option>" & sName & "</option>" &

vbCRLF

		sHold = sName

	End If

	oRS.MoveNext

  Loop 



  sListBox = sListBox & "</select>" & vbCRLF



  Response.Write ("<td>" & slistBox & "</td>")

  %>  



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: Thursday, March 29, 2001 4:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Just pass the value into the function using "this"



<SELECT onchange='getversions(this.value)'>



<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions(sPPO)

{  	

 	//... do whatever with sPPO

}	

</script>





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 2:00 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have 

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list 

box1. 



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px' 

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions()  

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita

Message #7 by "Peter Lanoie" <planoie@e...> on Fri, 30 Mar 2001 09:49:57 -0500
Rita,



Sounds like the cap fix worked, BUT... the getversions() function doesn't

return anything.

Look at the line I added in there...



function getversions()

{  	

 var sPPO = document.AddGroup.oPPONetworkID[document.AddGroup.oPPONetworkID.selectedIndex].value;



 return sPPO; // <-- you got the value ok, but need now to return it

}	



Try that out.



Peter



-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 10:38 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Peter.



Yup, that was a problem! However, when I made the change, it never returned

the value of what I had selected in the drop down list box. It's driving me

nuts! (:-P) It should work but is not. Any suggestions?



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Thursday, March 29, 2001 6:10 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



In your HTML, the form name is AddGroup (big G) but your javascript call to

it is a little g.

That get's me every time too! :)



Peter





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Wednesday, March 28, 2001 8:00 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list

box1.



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px'

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID

*/

function getversions()

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita

Message #8 by Rita Greenberg <rg1@h...> on Fri, 30 Mar 2001 08:28:07 -0800
Hi Alex.



Tried that with the same results.



I've changed my form so that I don't need to get the value of the dynamic

list box. It would be nice though to figure that one out!



Thanks for your help.



Rita



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: Friday, March 30, 2001 1:37 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Try replacing



sListBox = sListBox & "<option>" & sName & "</option>" 



with



sListBox = sListBox & "<option value=""" & sName & """>" & sName &

"</option>" &



-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 4:55 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Alex.



Thanks for this "simple" solution. However, when I tried it with my code I

got the value returned as nothing. What's interesting is that I create the

drop down list box dynamically from a record set. Just for the heck of it, I

added a regular drop down list box and "this.value" worked fine with that

one!



Here's my code for creating the dynamic list box:

  <%	

  'Populate drop down list box with recordset of Build PPO Network IDs 

  Dim sHold						'Don't populate

duplicate PPONetworkIDs

  

  oComm.CommandType = adCmdStoredProc



  oComm.CommandText = "rBUILDSSelAllProc"	'Stored Procedure name

  Set oRS = oComm.Execute()			'Return Builds

  

  sListBox = "<select id='oPPONetworkID' name='oPPONetworkID' style='width:

60px' onchange='getversions(this.value)'>" & vbCRLF

  Set sName = oRS.Fields("PPONetworkID")	'Build list box with

PPONetwork ID's

  

  Do Until oRS.EOF 

	If sHold <> sName Then			'Check for duplicate

PPONetworkIDs

		sListBox = sListBox & "<option>" & sName & "</option>" &

vbCRLF

		sHold = sName

	End If

	oRS.MoveNext

  Loop 



  sListBox = sListBox & "</select>" & vbCRLF



  Response.Write ("<td>" & slistBox & "</td>")

  %>  



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: Thursday, March 29, 2001 4:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Just pass the value into the function using "this"



<SELECT onchange='getversions(this.value)'>



<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions(sPPO)

{  	

 	//... do whatever with sPPO

}	

</script>





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 2:00 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have 

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list 

box1. 



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px' 

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID 

*/

function getversions()  

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita



---

SoftArtisans helps developers build robust, scalable Web applications!

Excel Web reports, charts: http://www.softartisans.com/excelwriter.html

File uploads: http://www.softartisans.com/saf.html

Transactional file management: http://www.softartisans.com/saf1.html

Scalability: http://www.softartisans.com/saxsession.html

ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html




$subst('Email.Unsub')

Message #9 by Rita Greenberg <rg1@h...> on Fri, 30 Mar 2001 08:26:04 -0800
Hi Peter.



I tried the "return" - wasn't sure where that was going! However, it took me

out of the function. I have an "alert" at the start of the function, and

then another one after the "return". I got the first alert message but not

the second.



I've changed my form so that I don't need to get the value of the dynamic

list box. It would be nice though to figure that one out!



Thanks for your help.



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Friday, March 30, 2001 6:50 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



Sounds like the cap fix worked, BUT... the getversions() function doesn't

return anything.

Look at the line I added in there...



function getversions()

{  	

 var sPPO 

document.AddGroup.oPPONetworkID[document.AddGroup.oPPONetworkID.selectedInde

x].value;



 return sPPO; // <-- you got the value ok, but need now to return it

}	



Try that out.



Peter



-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 10:38 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Peter.



Yup, that was a problem! However, when I made the change, it never returned

the value of what I had selected in the drop down list box. It's driving me

nuts! (:-P) It should work but is not. Any suggestions?



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Thursday, March 29, 2001 6:10 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



In your HTML, the form name is AddGroup (big G) but your javascript call to

it is a little g.

That get's me every time too! :)



Peter





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Wednesday, March 28, 2001 8:00 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list

box1.



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px'

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID

*/

function getversions()

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita



---

SoftArtisans helps developers build robust, scalable Web applications!

Excel Web reports, charts: http://www.softartisans.com/excelwriter.html

File uploads: http://www.softartisans.com/saf.html

Transactional file management: http://www.softartisans.com/saf1.html

Scalability: http://www.softartisans.com/saxsession.html

ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html




$subst('Email.Unsub')

Message #10 by "Peter Lanoie" <planoie@e...> on Fri, 30 Mar 2001 13:11:59 -0500
Well,



Return does just that. It returns you out of the function.  Also, it

"Returns" the value you put after it... so in order for you to get the value

you are assigning to sPPO, the function has to return it.  Any code after a

return will not be run as you've discovered.





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Friday, March 30, 2001 11:26 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Peter.



I tried the "return" - wasn't sure where that was going! However, it took me

out of the function. I have an "alert" at the start of the function, and

then another one after the "return". I got the first alert message but not

the second.



I've changed my form so that I don't need to get the value of the dynamic

list box. It would be nice though to figure that one out!



Thanks for your help.



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Friday, March 30, 2001 6:50 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



Sounds like the cap fix worked, BUT... the getversions() function doesn't

return anything.

Look at the line I added in there...



function getversions()

{  	

 var sPPO 

document.AddGroup.oPPONetworkID[document.AddGroup.oPPONetworkID.selectedInde

x].value;



 return sPPO; // <-- you got the value ok, but need now to return it

}	



Try that out.



Peter



-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 10:38 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Peter.



Yup, that was a problem! However, when I made the change, it never returned

the value of what I had selected in the drop down list box. It's driving me

nuts! (:-P) It should work but is not. Any suggestions?



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Thursday, March 29, 2001 6:10 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



In your HTML, the form name is AddGroup (big G) but your javascript call to

it is a little g.

That get's me every time too! :)



Peter





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Wednesday, March 28, 2001 8:00 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Get Value of List Box In a Function





Hi.



I have a drop down list box. When the user makes a selection, I have

an "onchange" event that calls a JavaScript function.



I'm having a problem getting the value of the selected option from list

box1.



Here's my <FORM> and <SELECT> statement:

<form name="AddGroup" method="post" action="addgroupinsert.asp">

<select id='oPPONetworkID' name='oPPONetworkID'  style='width: 60px'

onchange='getversions()'>



Here's my JavaScript function:

<script language="JavaScript">

/* Populate Build Version List Box with Versions for selected PPONetworkID

*/

function getversions()

{  	

 var sPPO = document.AddGroup.oPPONetworkID

[document.Addgroup.oPPONetworkID.selectedIndex].value

}	

</script>



I get the following error message:

  Error: 'document.Addgroup.oPPONetworkID[...] value' is null or not an 

object





What am I doing wrong??



TIA.



Rita







Message #11 by Rita Greenberg <rg1@h...> on Fri, 30 Mar 2001 12:07:49 -0800
Hi Peter. 



Thanks for the great explanation.



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Friday, March 30, 2001 10:12 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Well,



Return does just that. It returns you out of the function.  Also, it

"Returns" the value you put after it... so in order for you to get the value

you are assigning to sPPO, the function has to return it.  Any code after a

return will not be run as you've discovered.





-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Friday, March 30, 2001 11:26 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Peter.



I tried the "return" - wasn't sure where that was going! However, it took me

out of the function. I have an "alert" at the start of the function, and

then another one after the "return". I got the first alert message but not

the second.



I've changed my form so that I don't need to get the value of the dynamic

list box. It would be nice though to figure that one out!



Thanks for your help.



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Friday, March 30, 2001 6:50 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



Sounds like the cap fix worked, BUT... the getversions() function doesn't

return anything.

Look at the line I added in there...



function getversions()

{  	

 var sPPO 

document.AddGroup.oPPONetworkID[document.AddGroup.oPPONetworkID.selectedInde

x].value;



 return sPPO; // <-- you got the value ok, but need now to return it

}	



Try that out.



Peter



-----Original Message-----

From: Rita Greenberg [mailto:rg1@h...]

Sent: Thursday, March 29, 2001 10:38 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Hi Peter.



Yup, that was a problem! However, when I made the change, it never returned

the value of what I had selected in the drop down list box. It's driving me

nuts! (:-P) It should work but is not. Any suggestions?



Rita



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Thursday, March 29, 2001 6:10 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Get Value of List Box In a Function





Rita,



In your HTML, the form name is AddGroup (big G) but your javascript call to

it is a little g.

That get's me every time too! :)



Peter




  Return to Index