Hi there,
I explain the context. I wrote a dynamic html form (with a button to add fields) because our CMS (Episerver) is too limited. Then I found an ASP function (on the web cause I have no knowkedge in ASP as a simple Intranet editor) to send data to a mail address. The sending is fine but I don't know how to put the values of the generated fields in the body since I do not know how many fields would be filled (can I use a variable?).
Here are my asp function and my form fields below. Thanks in advance for any provided help!
ASP Function:
Code:
<%
If Request.Form("btnSubmit") <> "" Then
Dim Message
Message =
Const cdoSendUsingPort = 2
Dim oConfiguration
Dim oMessage
Dim oFields
Set oMessage = CreateObject("CDO.Message")
Set oConfiguration = CreateObject("CDO.Configuration")
Set oFields = oConfiguration.Fields
' Set the CDOSYS configuration fields to use port
' 25 on the SMTP server.
With oFields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") _
= cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= "mailhost.XXX.net"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") _
= 10
.Update
End With
' Apply the settings to the message.
With oMessage
Set .Configuration = oConfiguration
.To = "XX.XX@XX.com"
.Bcc = ""
.From = request.form("txtName")
.Subject = request.form("txtName") & " requests a publication"
.HTMLBody = Message
.Send
End With
' Clean up variables.
Set oMessage = Nothing
Set oConfiguration = Nothing
Set oFields = Nothing
Response.Redirect("XXX")
End If
%>
Form fields:
Code:
<!--
var i=1;
var input_add;
function create_champ(){
var newDiv = input_add.parentNode.insertBefore( document.createElement('div'), input_add );
newDiv.id = 'champs_'+i;
newDiv.innerHTML = '<table><tbody><tr><td>Title</td><td colspan="5"><input name="title_'+i+'" id="ti_'+i+'" size="40" type="text"/></td></tr><tr><td>Author</td><td colspan="5"><input name="author_'+i+'" id="au_'+i+'" size="30" type="text"/></td></tr><tr><td>Journal</td><td colspan="5"><input name="journal_'+i+'" id="so_'+i+'" size="30" type="text"/></td></tr><tr><td style="width: 65px;">Year</td><td style="width: 65px;"><input name="year_'+i+'" id="ye_'+i+'" size="4"type="text"/></td><td style="width: 65px;">Volume</td><td style="width: 65px;"><input name="volume_'+i+'" id="vol_'+i+'" size="4"type="text"/></td><td style="width: 60px;">Pages</td><td style="width: 65px;"><input name="pages_'+i+'" id="pa_'+i+'" size="4"type="text"/></td></tr></tbody></table><br>';
if(i>1) document.getElementById('input_sup').style.display = 'inline';
if(i>100) input_add.style.display = 'none';
i++;
}
|