• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

Populating a text area

I am using the code below to try and populate a textarea (StoresList) based on the value from my select box (cboDate).  

However, as you might be able to guess it is not populating anything.  I also thought I would try populating another select box with the Stores Value but none of this is working.  Any clue how I am messing this up?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
<SCRIPT LANGUAGE=javascript>
<!--
 
function submitStores(){
	var objForm = document.forms[0];
	objForm.submit();
}
//-->
</SCRIPT>
 
<% 
sub updateStores()
     GEOID = Request.QueryString("id")
        Dim oRSbn
	    'Create the recordset object
	    Set oRSbn = Server.CreateObject("ADODB.Recordset")
    oRSbn.CursorType= 3 
    oRSbn.LockType = 1 
    oRSbn.CursorLocation = 3
	    'Open the recordset getting a list of all Divisions
        sqltext = "SELECT CHART_A.STORES, CHART_A.Event_Date FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.Event_Date, CHART_A.GEOID HAVING (((CHART_A.GEOID)='10420')) ORDER BY CHART_A.[Event_Date];"
 
 
        oRSbn.open sqltext, "DSN=CompEvents"
         'go to first record.
        oRSbn.MoveFirst
 
    do while not oRSbn.eof        
        Response.Write("<option" & oRSbn("STORES") & ">" & oRSbn("STORES") & "</option>")
        'Response.Write("<textarea name ="StoresList" style="width: 933px; height: 50px;" > oRSbn("STORES") </textarea>")
       oRSbn.movenext
    loop
    oRSbn.close
    set oRSbn = nothing
 
end sub
%>
 
 
 
 
</head>
<body>
 
<form action="" method="post" name="frmDisplay" onSubmit="return submitForm()">
  <input type="hidden" name="FormAction" >
<br />
 
    <TD style="width: 150px; height: 73px;"><STRONG><EM>Choose Date:<br />
        <SELECT name=cboDate size=1 ID="Date" onChange = "submitStores()">
<%    
	'Create the recordset object
        Dim oRSbn
 
	Set oRSbn = Server.CreateObject("ADODB.Recordset")
	'Open the recordset getting a list of all Dates for this Market
    sqltext = "SELECT CHART_A.Event_Date FROM CHART_A GROUP BY CHART_A.Event_Date, CHART_A.GEOID HAVING (((CHART_A.GEOID)='10420')) ORDER BY CHART_A.[Event_Date];"
    oRSbn.open sqltext, "DSN=CompEvents"
     'go to first record.
    oRSbn.MoveFirst
        do while not oRSbn.eof
%>        
<option value="<%=oRSbn("Event_Date")%>"> <%=oRSbn("Event_Date")%></option>
<%
        oRSbn.movenext
        loop
    oRSbn.close
    set oRSbn = nothing    
 %>   
    
    </SELECT></EM></STRONG></TD>
 
 
<SELECT style="WIDTH: 200px; HEIGHT: 125px" multiple size=2 id=selType name=selType> 
			<%call updateStores%>
	  </SELECT>
<br />
 
     <textarea name ="StoresList" style="width: 933px; height: 50px;" > <% call updateStores%>  </textarea>
</form>
 
</body>
</html>

Open in new window

0
flfmmqp
Asked:
flfmmqp
  • 6
  • 4
1 Solution
 
silemoneCommented:
Did you get any errors?  any output?  try using alert boxes/message boxes to see it there is any data?  it may be your query is not returning any data...
0
 
rlovetxCommented:
Hi,
      You need to populate the textarea with your JavaScript...something like this:

document.getElementById("StoresList").value = myData;

     Where myData is the value you want to appear in the TextArea.  You also need to add some JavaScript to check your select value and set myData accordingly.


0
 
flfmmqpAuthor Commented:
Augh.  Okay I still have the same two problems.

1.) Getting the date from the select box.
2.) Populating the new data into the text area when the date changes.

Any help would be greatly appreciated.  Here is my updated code.  I think I am getting closer.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
 
<SCRIPT LANGUAGE=javascript>
<!--
 
function submitStores(){
	var objForm = document.forms[0];
	objForm.submit();
}
//-->
</SCRIPT>
 
<% 
sub updateStores()
dim GEOID, strDate, strDate2
    //strDate2 = Request.Form("Date")
    
     GEOID = Request.QueryString("id")
    strDate = "01/2006"
 
        Dim oRSbn
	    'Create the recordset object
	    Set oRSbn = Server.CreateObject("ADODB.Recordset")
    oRSbn.CursorType= 3 
    oRSbn.LockType = 1 
    oRSbn.CursorLocation = 3
	    'Open the recordset getting a list of all Divisions
        //sqltext = "SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='01/2004') AND ((CHART_A.GEOID)='" & GEOID & "')) ORDER BY CHART_A.DATE2;"
        sqltext = "SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='" & strDate & "') AND ((CHART_A.GEOID)='" & GEOID & "')) ORDER BY CHART_A.DATE2;"
 
 
        oRSbn.open sqltext, "DSN=CompEvents"
         'go to first record.
        oRSbn.MoveFirst
 
    do while not oRSbn.eof        
        response.Write(oRSbn("STORES"))
       response.Write ("GEOID = " & GEOID & " strDate2 = " & strDate2)
       oRSbn.movenext
    loop
    oRSbn.close
    set oRSbn = nothing
 
end sub
%>
 
</head>
<body>
 
<form action="" method="post" name="frmDisplay" onSubmit="return submitForm()">
  <input type="hidden" name="FormAction" >
<br />
 
    <TD style="width: 150px; height: 73px;"><STRONG><EM>Choose Date:<br />
        <SELECT name=selDate size=1 ID="selDate" onChange = "submitStores()">
<%    
	'Create the recordset object
	Set oRSbn = Server.CreateObject("ADODB.Recordset")
	'Open the recordset getting a list of all Dates for this Market
    'sqltext = "SELECT CHART_A.[Date2] FROM CHART_A GROUP BY CHART_A.GEOID, CHART_A.[Date2] HAVING (((CHART_A.GEOID)='517')) ORDER BY CHART_A.[Date2];"
    sqltext = "SELECT CHART_A.Date2 FROM CHART_A GROUP BY CHART_A.Date2, CHART_A.GEOID HAVING (((CHART_A.GEOID)='517')) ORDER BY CHART_A.[Date2];"
 
    oRSbn.open sqltext, "DSN=CompEvents"
     'go to first record.
    oRSbn.MoveFirst
        do while not oRSbn.eof
%>        
<option value="<%=oRSbn("Date2")%>"> <%=oRSbn("Date2")%></option>
<%
        oRSbn.movenext
        loop
    oRSbn.close
    set oRSbn = nothing    
 %>   
    
    </SELECT></EM></STRONG></TD>
 
 
<SELECT style="WIDTH: 200px; HEIGHT: 125px" multiple size=2 id=selType name=selType> 
			<%call updateStores%>
	  </SELECT>
<br />
 
     <textarea name ="StoresList" style="width: 933px; height: 356px;" > <% call updateStores%>  </textarea>
    <br />
    C:\Inetpub\wwwroot\CHART\DMA_Chart_DataTable2.asp
</form>
 
</body>
</html>

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
rlovetxCommented:
Hey,
     The easiest way would be to change your form from post to get and have its action set to the same page.  This will pass your form data as a querystring.
     You can then add some ASP code to read the querystring values and update your selType select when the page refreshes.
     Other options:  update selType using JavaScript (this will mean having to write JavaScript data with ASP so you can update selType in this way), or you could look into Ajax...
0
 
flfmmqpAuthor Commented:
No Ajax.  Can you help me with the code.  I am fine with the easiest way.  I like easy.
0
 
rlovetxCommented:

Change:
<form action="" method="post" name="frmDisplay" onSubmit="return submitForm()">
To:
<form action="samepage.asp" method="post" name="frmDisplay" onSubmit="return submitForm()">
 
Add something like this to the top of the page...
 
<%
Dim strselDate
strselDate = Request.Form("selDate")
%>
 
Then change your routine to include an if/then...
 
<% 
sub updateStores()
     If strselDate <> "" Then
dim GEOID, strDate, strDate2
    //strDate2 = Request.Form("Date")
    
     GEOID = Request.QueryString("id")
    strDate = "01/2006"
 
        Dim oRSbn
	    'Create the recordset object
	    Set oRSbn = Server.CreateObject("ADODB.Recordset")
    oRSbn.CursorType= 3 
    oRSbn.LockType = 1 
    oRSbn.CursorLocation = 3
	    'Open the recordset getting a list of all Divisions
        //sqltext = "SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='01/2004') AND ((CHART_A.GEOID)='" & GEOID & "')) ORDER BY CHART_A.DATE2;"
        sqltext = "SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='" & strDate & "') AND ((CHART_A.GEOID)='" & GEOID & "')) ORDER BY CHART_A.DATE2;"
 
 
        oRSbn.open sqltext, "DSN=CompEvents"
         'go to first record.
        oRSbn.MoveFirst
 
    do while not oRSbn.eof        
        response.Write(oRSbn("STORES"))
       response.Write ("GEOID = " & GEOID & " strDate2 = " & strDate2)
       oRSbn.movenext
    loop
    oRSbn.close
    set oRSbn = nothing
Else
    Response.Write("Select a date to see this info.")
End If
end sub
%>

Open in new window

0
 
flfmmqpAuthor Commented:
I keep getting a blank date.  I think I might need to somehow get the date value from the post that you were referring to but I am not sure exactly how to do this.

SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='') AND ((CHART_A.GEOID)='517')) ORDER BY CHART_A.DATE2;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
 
<SCRIPT LANGUAGE=javascript>
<!--
 
function submitStores(){
	var objForm = document.forms[0];
	objForm.submit();
}
//-->
</SCRIPT>
 
<%
 
Dim strselDate
strselDate = Request.Form("selDate")
dim strGEOID, varGEOID
strGEOID = Request.QueryString("id")
 
%>
 
<% 
sub updateStores()
       
 dim varGEOID
 
         sqltext = "SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='" & strselDate & "') AND ((CHART_A.GEOID)='517')) ORDER BY CHART_A.DATE2;"
     If strselDate <> "" Then
            Response.Write("Date Chosen" & strselDate)
     
        dim strDate, strDate2
 
        Dim oRSbn
	    'Create the recordset object
	    Set oRSbn = Server.CreateObject("ADODB.Recordset")
        oRSbn.CursorType= 3 
        oRSbn.LockType = 1 
        oRSbn.CursorLocation = 3
	    'Open the recordset getting a list of all Divisions
        //sqltext = "SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='01/2004') AND ((CHART_A.GEOID)='" & GEOID & "')) ORDER BY CHART_A.DATE2;"
        sqltext = "SELECT CHART_A.STORES, CHART_A.DATE2 FROM CHART_A GROUP BY CHART_A.STORES, CHART_A.DATE2, CHART_A.GEOID HAVING (((CHART_A.DATE2)='" & strselDate & "') AND ((CHART_A.GEOID)='517')) ORDER BY CHART_A.DATE2;"
        oRSbn.open sqltext, "DSN=CompEvents"
         'go to first record.
        oRSbn.MoveFirst
 
        do while not oRSbn.eof
            response.Write(oRSbn("STORES"))
            response.Write (sqltext)        
           oRSbn.movenext
        loop
        oRSbn.close
        set oRSbn = nothing
    Else
        Response.Write("Select a date to see this info.")
        response.Write(sqltext)
    End If
end sub
%> 
 
 
</head>
<body>
 
<form action="" method="get" name="frmDisplay" onSubmit="return submitForm()">
  <input type="hidden" name="id" >
<br />
 
    <TD style="width: 150px; height: 73px;"><STRONG><EM>Choose Date:<br />
        <SELECT name=selDate size=1 ID="selDate" onChange = "submitStores()">
<%    
	'Create the recordset object
	Set oRSbn = Server.CreateObject("ADODB.Recordset")
	'Open the recordset getting a list of all Dates for this Market
    'sqltext = "SELECT CHART_A.[Date2] FROM CHART_A GROUP BY CHART_A.GEOID, CHART_A.[Date2] HAVING (((CHART_A.GEOID)='517')) ORDER BY CHART_A.[Date2];"
    sqltext = "SELECT CHART_A.Date2 FROM CHART_A GROUP BY CHART_A.Date2, CHART_A.GEOID HAVING (((CHART_A.GEOID)='517')) ORDER BY CHART_A.[Date2];"
 
    oRSbn.open sqltext, "DSN=CompEvents"
     'go to first record.
    oRSbn.MoveFirst
        do while not oRSbn.eof
%>        
<option value="<%=oRSbn("Date2")%>"> <%=oRSbn("Date2")%></option>
<%
        oRSbn.movenext
        loop
    oRSbn.close
    set oRSbn = nothing    
 %>   
    
    </SELECT></EM></STRONG></TD>
 
 
<SELECT style="WIDTH: 200px; HEIGHT: 125px" multiple size=2 id=selType name=selType> 
			<%call updateStores%>
	  </SELECT>
<br />
 
     <textarea name ="StoresList" style="width: 933px; height: 356px;" > <% call updateStores%>  </textarea>
    <br />
    C:\Inetpub\wwwroot\CHART\DMA_Chart_DataTable2.asp
</form>
 
</body>
</html>

Open in new window

0
 
flfmmqpAuthor Commented:
ignore last comment for now.
0
 
flfmmqpAuthor Commented:
Okay we are getting closer.  One small problem.  I lose my GEOID with the post.  I was getting it from the url like this before - http://ho000xd3840571/CHART/DMA_Chart_DataTable2.asp?id=517
strGEOID = Request.QueryString("id")

I need this for the query.  How can I keep it?
0
 
flfmmqpAuthor Commented:
Can I do something like this?
<form action="DMA_Chart_DataTable2.asp?id=" & "<% Request.QueryString("id") %>" method="post" name="frmDisplay" onSubmit="return submitForm()">
0
 
rlovetxCommented:
An easier solution...
Set your GEOID in a hidden field:  <input type=hidden value=<% =GEOID %> id=myGeoID />
On the refresh, in your sub, use:
Dim myGEOID
myGEOID = Request.Form("myGeoID")
and you're back in business.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now