472,789 Members | 1,227 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

Output of select values are numerals instead of state and county

I have a dynamic pulldown list (ASP with javascript) that when a user
picks a state, the corresponding counties for that state appear in a
dynamic second pulldown list. When I submit the form, the values for
state and county are numerals 1 (for the state) and 2 (for the county
selected) and not the values for the state and county
????
any help appreciated!
<!--#include file="dbaseconnection.asp" -->
<%
Dim rsMain
Dim rsMain_numRows

Set rsMain = Server.CreateObject("ADODB.Recordset")
rsMain.ActiveConnection = conn_STRING
rsMain.Source = "SELECT * FROM state_details ORDER BY state2 ASC"

rsMain.Open()

rsMain_numRows = 0
%>
<%
Dim rsSub
Dim rsSub_numRows

Set rsSub = Server.CreateObject("ADODB.Recordset")
rsSub.ActiveConnection = conn_STRING
rsSub.Source = "SELECT * FROM county_details ORDER BY county ASC"

rsSub.Open()

rsSub_numRows = 0
%>

<script language="JavaScript">
<!--

var arrDynaList = new Array();
var arrDL1 = new Array();

arrDL1[1] = "state"; // Name of parent list box
arrDL1[2] = "form1"; // Name of form containing parent list box
arrDL1[3] = "county"; // Name of child list box
arrDL1[4] = "form1"; // Name of form containing child list box
arrDL1[5] = arrDynaList; // No need to do anything here

<%
Dim txtDynaListRelation, txtDynaListLabel, txtDynaListValue,
oDynaListRS

txtDynaListRelation = "fkid" ' Name of recordset field relating to
parent
txtDynaListLabel = "county" ' Name of recordset field for child
Item Label
txtDynaListValue = "couid" ' Name of recordset field for child
Value
Set oDynaListRS = rsSub ' Name of child list box recordset

Dim varDynaList
varDynaList = -1

Dim varMaxWidth
varMaxWidth = "1"

Dim varCheckGroup
varCheckGroup = oDynaListRS.Fields.Item(txtDynaListRelation).Value

Dim varCheckLength
varCheckLength = 0

Dim varMaxLength
varMaxLength = 0

While (NOT oDynaListRS.EOF)

If (varCheckGroup <>
oDynaListRS.Fields.Item(txtDynaListRelation).Value ) Then
If (varCheckLength varMaxLength) Then
varMaxLength = varCheckLength
End If
varCheckLength = 0
End If
%>
arrDynaList[<%=(varDynaList+1)%>] = "<
%=(oDynaListRS.Fields.Item(txtDynaListRelation).Va lue)%>"
arrDynaList[<%=(varDynaList+2)%>] = "<
%=(oDynaListRS.Fields.Item(txtDynaListLabel).Value )%>"
arrDynaList[<%=(varDynaList+3)%>] = "<
%=(oDynaListRS.Fields.Item(txtDynaListValue).Value )%>"
<%
If (len(oDynaListRS.Fields.Item(txtDynaListLabel).Val ue) >
len(varMaxWidth)) Then
varMaxWidth = oDynaListRS.Fields.Item(txtDynaListLabel).Value
End If
varCheckLength = varCheckLength + 1
varDynaList = varDynaList + 3
oDynaListRS.MoveNext()
Wend

If (varCheckLength varMaxLength) Then
varMaxLength = varCheckLength
End If
%>

//-->
</script>
<script language="JavaScript">
<!--
function setDynaList(arrDL){

var oList1 = document.forms[arrDL[2]].elements[arrDL[1]];
var oList2 = document.forms[arrDL[4]].elements[arrDL[3]];
var arrList = arrDL[5];

clearDynaList(oList2);

if (oList1.selectedIndex == -1){
oList1.selectedIndex = 0;
}

populateDynaList(oList2, oList1[oList1.selectedIndex].value,
arrList);
return true;
}

function clearDynaList(oList){

for (var i = oList.options.length; i >= 0; i--){
oList.options[i] = null;
}

oList.selectedIndex = -1;
}

/*This is a modified function from the original MM script. Mick White
added the first line of oList so there would be an initial selection.
Needed this if there is only 1 child menu item, otherwise, the single
child menu item would be already hihghlighted and you can not select
it. Also good for validation purposes so you can set the .js
validation to not allow the first selection.
*/

function populateDynaList(oList, nIndex, aArray){
oList[oList.length]= new Option("Please Select");
for (var i = 0; i < aArray.length; i= i + 3){
if (aArray[i] == nIndex){
oList.options[oList.options.length] = new Option(aArray[i + 1],
aArray[i + 2]);
}
//oList.size=oList.length //You need to comment out this line of the
function if you use this mod
}

//A quick mod here, I changed the ==0 to ==1 so that the length
//takes into account the Please select option from above.
if (oList.options.length == 1){
oList.options[oList.options.length] = new Option(":: No
SubCategories Available ::");
}
oList.selectedIndex = 0;
}

//-->
</script>

<select name="state" id="state" size="10"
onChange="setDynaList(arrDL1)" class="select-type1">
<%
While (NOT rsMain.EOF)
%>
<option value="<%=(rsMain.Fields.Item("staid").Value)%>"><
%=(rsMain.Fields.Item("statefull").Value)%></option>
<%
rsMain.MoveNext()
Wend
If (rsMain.CursorType 0) Then
rsMain.MoveFirst
Else
rsMain.Requery
End If
%>
</select>
<!-- here's the child/sub box 'county' , will display under not
side by side -->
<select name="county" id="county" size="10" class="select-type1">
</select>
<%
rsMain.Close()
Set rsMain = Nothing
%>
<%
rsSub.Close()
Set rsSub = Nothing
%>

Mar 26 '07 #1
5 1737
Lee
Bubba said:
>
I have a dynamic pulldown list (ASP with javascript) that when a user
picks a state, the corresponding counties for that state appear in a
dynamic second pulldown list. When I submit the form, the values for
state and county are numerals 1 (for the state) and 2 (for the county
selected) and not the values for the state and county
????
any help appreciated!
This is a Javascript newsgroup. Please post the Javascript code
and related HTML, not your server-side code that generates it.
--

Mar 26 '07 #2
I did just that, I posted all the javascript blocks. sorry for it
being lengthy (as i needed to post the accompanying ASP/sql , and the
form tags)
On Mar 26, 11:00 am, Lee <REM0VElbspamt...@cox.netwrote:
Bubba said:
I have a dynamic pulldown list (ASP with javascript) that when a user
picks a state, the corresponding counties for that state appear in a
dynamic second pulldown list. When I submit the form, the values for
state and county are numerals 1 (for the state) and 2 (for the county
selected) and not the values for the state and county
????
any help appreciated!

This is a Javascript newsgroup. Please post the Javascript code
and related HTML, not your server-side code that generates it.

--

Mar 26 '07 #3
Lee
Bubba said:
>
I did just that, I posted all the javascript blocks. sorry for it
being lengthy (as i needed to post the accompanying ASP/sql , and the
form tags)
I'm saying to leave out the ASP code.
Show us *only* the generated page.
--

Mar 26 '07 #4
Bubba said the following on 3/26/2007 2:32 PM:
I did just that, I posted all the javascript blocks. sorry for it
being lengthy (as i needed to post the accompanying ASP/sql , and the
form tags)
No, you posted the ASP code that generates your HTML/JS. Open your page
in the browser, right click>View Source and post *that* source code. Or,
even better, is to post a URL to a sample page.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 26 '07 #5
On Mon, 26 Mar 2007 18:17:06 +0200, Bubba <ar*****@yahoo.comwrote:
oList.options[oList.options.length] = new Option(aArray[i + 1],
aArray[i + 2]);
This line states that every option will have both a text and an associated
value. I didn't read that deep into the code, but if that associated value
is a numeral, that's also what your form will submit.

To overcome, change it into this:
oList.options[oList.options.length] = new Option(aArray[i + 1]);
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Mar 31 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul Moberg | last post by:
MySQL 4.0.13-nt I have a table: CREATE TABLE state_county ( StCo_key bigint(20) NOT NULL auto_increment, State varchar(255) NOT NULL default '', County varchar(255) NOT NULL default '',...
5
by: Glenn | last post by:
Hi! Server info - Win2K3 Server +SP1 with 1 GB Memory and 1.5 GB Virtual Memory SQL Server 2000 Enterprise Edition + SP3 running on this. Required result - Create a SQL Script that will...
6
by: Mutley | last post by:
I am finding an issue with the current DropDownList and ListBox ASP.NET Web Controls. I had a system set up for Arabic and a string that I put into a drop down had a number. The letters were being...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
8
by: lli | last post by:
Hi Guys, I built a select in a form. My select is: print '<SELECT NAME="county">' print '<OPTION VALUE="000">ALL' print '<OPTION VALUE="001">AAA' print '<OPTION VALUE="002">BBB' print...
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
8
by: TGEAR | last post by:
I have an ItemSTDPriceHistory table as below and this is a child table of itemlookup table with one to many relationship. if exists (select * from dbo.sysobjects where id = object_id(N'.') and...
2
by: Tarik Monem | last post by:
OK! I've gone through a few tutorials and I cannot understand what I'm doing wrong casting_registration.php <table> <tr> <td> <form enctype="multipart/form-data" action="thankyou.php"...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.