Click to See Complete Forum and Search --> : autopopulating


radujit
07-10-2010, 07:40 PM
Hi,
Here is what I want to do:
I have a database and a table called templates.
Also I have an asp page which contains a form called "send" that gets data from templates. The form contains a listbox for choosing the id of template, and two textboxes (on for the subject and one for the message).

What i want to do is to populate the list from the templates recordset; then depending on selected value from the list box, subject and message to autopopulate.

Here is what I did so far:



<%
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("../database/beach.mdb")


set rs1 = server.CreateObject ("ADODB.Recordset")
rs1.Open "SELECT * FROM templates", conn, 3, 3

%>


<table border="1" cellspacing="0" bgcolor="#FFF4DC" bordercolor="#C08195" style="border-collapse: collapse" cellpadding="0">
<form method="POST" onsubmit="return Form_Validator(this)" action="sendpar_msg.asp" name="send">
<tr><td align="center" bgcolor="#C08195" colspan="2">
<font size="1" color="#FFFFFF">
<span style="font-family: Verdana; font-weight: 700">.::Trimite email
partener</span></font><font style="color: #FFFFFF; font-family: Verdana; font-weight: bold" size="1">::.</font></td></tr>

<tr>
<td bgcolor="#FFF4DC">
<font face="Verdana" size="1">&nbsp;Selecteaza sablon&nbsp; </font>
</td>
<td bgcolor="#FFF4DC">
<font face="Verdana" size="1">

<%
If Not rs1.EOF Then

rs1.MoveFirst
%>
<script type="text/vbscript" language="vbscript">

dim pubArray()

function applytoLabel(a)

if a.SelectedIndex = 0 then

document.send.subiect.value = ""
document.send.mesaj.value = ""


else
document.send.subiect.value = a.value
document.send.mesaj.value = a.name


end if

end function</script>

<select name="tip" onChange="applytoLabel(this)" style="font-family: Tahoma; color: #0066FF; font-size: 10pt" size="1">

<option></option>

<%

x = 0

Do While Not rs1.EOF
%>

<script language="vbscript">

ReDim Preserve pubArray(<%= x %>)

pubArray(<%= x %>) = "<%= Rs1.Fields("id").Value %>"



</script>

<option value="<%= RS1.Fields("subiect") %>"><%= RS1.Fields("subiect") %></option>

<%

x = x + 1
%>

<%

RS1.MoveNext

Loop

%>

</select>


<% end if %>


</font>&nbsp;</td>
</tr>

<tr>
<td bgcolor="#FFF4DC">
<font face="Verdana" size="1">&nbsp;Subiect </font>
</td>
<td bgcolor="#FFF4DC">
<font style="color: #000000; font-family: Verdana" size="1">
<input type="text" name="subiect" maxlength="50" size="59" style="font-family: Verdana; border-style: solid; border-width: 1; font-size:8pt" >
<%if request.querystring("to")<>"" then%>
<input type="hidden" name="to" maxlength="50" size="25" style="font-family: Verdana; border-style: solid; border-width: 1; font-size:8pt" value="<%=objto("email")%>" ></font>
<%else%>
<input type="hidden" name="to" maxlength="50" size="25" style="font-family: Verdana; border-style: solid; border-width: 1; font-size:8pt" value="<%=list%>" ></font>
<%end if%>
<font face="Verdana" size="1">
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4DC">
&nbsp;</td>
<td bgcolor="#FFF4DC">
&nbsp;</td>
</tr>

<tr>
<td bgcolor="#FFF4DC">
<font face="Verdana" size="1">&nbsp;Mesaj: </font>
</td>
<td bgcolor="#FFF4DC">
<font style="color: #000000; font-family: Verdana" size="1">
<input type="text" name="mesaj" id="message" cols="57" rows="19" style="font-family: Verdana; border: 1px solid #000000; font-size:8pt" size="20"></font><font face="Verdana" size="1">
</font>
</td>
</tr>

<tr>
<td bgcolor="#FFF4DC" colspan="2">
<p align="center">
<font face="Verdana" size="1">
<input type="submit" name="Submit" value="Trimite!" style="border:1px solid #000000; font-family: Verdana; font-size: 8pt; font-weight: bold; color:#C08195; background-color:#FFFFFF">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="Reset" value="Sterge" style="border:1px solid #000000; font-family: Verdana; font-size: 8pt; font-weight: bold; color:#C08195; background-color:#FFFFFF">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" name="close" value="Inchide" onclick="javascript:window.close();" style="border:1px solid #000000; font-family: Verdana; font-size: 8pt; font-weight: bold; color:#C08195; background-color:#FFFFFF"></font></td>
</tr>


</form>
</table>


What this code at this moment does is to load templates into the list and when I select the template, autopopulates the subject only (not populating the mesage box).
I am stuck with this code for a couple of days now.
Please help