Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert (new) records in a table => question about the inputscreen

Status
Not open for further replies.

leifoet

Technical User
Jan 31, 2016
206
BE
I use two forms : input + entry
form input => e.g. input a Name
form entry => create new record with the Name in table A (with form inmput : method="post" action="form_entry.asp">

Is it possible while inputing the name to get (to see) in the same input form also the e-mail address -corresponding to the Name- from table B ?

I have no problem to create a list with data-combinations from (table A + table B) with a selectionquery, after the imput, but is it possible to fix my question 'during' the input ?

Or is that completely impossible ?
Thanks for tips - Leifoet

How -on the easiest way-
(1) get the email address of the Name from Table B and to appear in the input box Name in nput
 
Not with ASP code, you would have to use an AJAX request to that information from the table.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Supertip ! Thanks.
This application was unknown to me.

I want also to 'input' the selected emailaddress for immediately use in an automaticly created e-mail message (prior to storage in the table).
I tried to input the selected emailadress with the code in red below => error.
How can I become that (e.g. => Request.Form("a_email")?
Thanks for tips - Leifoet

<%
response.expires=-1
sql="SELECT emailadress, GSM FROM ldn WHERE Lastname="
sql=sql & "'" & request.querystring("q") & "'"

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("users.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
rs.Open sql,conn

response.write("<table>")
do until rs.EOF
for each x in rs.Fields
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td>" & x.value & "</td></tr>")

if x.name = "emailadress" then%>
<input type="hidden" name="a_email" value="x.value">
<%end if

next
rs.MoveNext
loop
response.write("</table>")

%>
 
This application was unknown to me.
???

AJAX is not an 'application', it is an acronym for "Asynchronous javascript and XML", and based on all your current threads is something that you need to learn before before you go much further into ASP. Because nothing you have asked so far can be done with vbscript running in the context of ASP (Active Server Pages) with the emphasis being on Server. ASP scripts run on the server then cease to operate as the document data stream has been served out to the user agent. Users do not interact with the server side code AT ALL, without there being an new request made for an updated document by pressing a [ Submit ] button for example, where the code reads the Form (POST) data or the query string (GET) data and re-processes the script with the new parameters that have been provided.



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Whoops sorry wrong person asking eerily similar questions.



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
My present situation (combination ASP / AJAX)
=> using Form1 => input (other data) + name => AJAX retrieves (from database) the mailadress (corresponding with the name (using the separate AJAX file named 'retriever')
=> using Form2 => processing of the data of form1 - method="post" = sending the data in a mail to the retrieved mailadress and inserting the data in a database-table

Inserting in a table = OK
Sending the mails = (OK) if not to an email address with an underscore in the address
For an emailaddress with an underscore, the message is not sent, even if this address is in the 'FROM'-section

This is my custom AJAX code (my 'retriever' file)
(Original AJAX file => W3School AJAX Database getcustomer.asp)

<%
response.expires=-1
sql="SELECT emailadress, GSM FROM ldn WHERE LName="
sql=sql & "'" & request.querystring("q") & "'"

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("_private/FOCO.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
rs.Open sql,conn

Dim GSM
Dim mail

' response.write("<table>")
do until rs.EOF
for each x in rs.Fields
' response.write("<tr><td><b>" & x.name & "</b></td>")
' response.write("<td>" & x.value & "</td></tr>")

if x.name = "emailadress" then
Session("mail") = x.value
else
Session("GSM") = x.value
end if

next
rs.MoveNext
loop
'response.write("</table>")

%>
<p><INPUT TYPE="hidden" SIZE="30" NAME="email" value="<%response.write Session("mail")%>"></p>

This code sends the mailadress to the mail module when the user presses the submit button in Form1
Apparently this does not happen if there is an underscore in the e-mail address.
I do not understand why the problem occurs only with a underscore (in the emailadress).

The first lines of my mail module are :
<%
Dim objCDOMail
Dim Sender
Sender = Session("mail")

Set objCDOMail = CreateObject("CDONTS.NewMail")

objCDOMail.To = "myself@abc.cd"
objCDOMail.From = sender
...

Thanks for help / tips - Leifoet
 
Underscores was just one of several problems CDONTS had, you should be using CDOSYS instead.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Used CDOSYS from W3School :

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From=Session("mail")
myMail.To="myself@abc.de"
' myMail.Bcc="someoneelse@somedomain.com"
' myMail.Cc="someoneelse2@somedomain.com"
myMail.TextBody="This is a testmessage."
myMail.Send
set myMail=nothing

Mailadress with underscore (Fname_Lname@....) not received (vs a message with an address without underscore I did receive).
What can it be ? Thanks for tips - Leifoet
 
Are both addresses:

On the same domain?
On the same server?
Have you checked the responses from the .send() function?
Have you checked the incoming logs on the recipient server?
Run a delivery trace from the outgoing server for both addresses?



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Today I tested 2 adresses :
=>FROM LastnameFirstname@hotmail.com TO myself (other domain/server) => OK =received
=>FROM Firstname_Lastname@yahoo.com TO myself => NOK
earlier I tested FROM with several other adresses TO myself => all OK (received)

My problem : how can I check the responses from the send() function ?
What do you mean with incoming logs on the recipient server ? Is that my INboox ?

I asked my outgoing server to deliver ASAP the delivery trace for the adresses.

While writing I was thinking the following : is there a possibility in this case that Yahoo stops the Yahoo-address from the FROM-section (of my test), and consequently stops the entire email? (or is this not done)

Thanks - Leifoet
 
how can I check the responses from the send() function


The same way you would get or show the return value from any function,

x = function() and 'x' has the returned value.


is there a possibility in this case that Yahoo stops the Yahoo-address from the FROM-section (of my test), and consequently stops the entire email
Of course, have you checked if a yahoo address without an underscore receives a message from the same script?

Testing one server with an underscore and a different server without is not a useful comparison it tells you nothing about the script or the server it is running on.

Have you set the script to relay via a SMTP server and then tested?
Does the server or the machine that the script is running on have a valid reverse DNS pointer?
Does it have a valid host name?

There are lots of reasons why Yahoo! MX servers would 'blackhole' incoming messages.


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 

Now I have done it (tested a Yahoo adress without underscore) => NOK - no email received.
Conclusion: a yahoo address in the FROM section fails (?)

When I put the Yahoo addresses in the TO section, and the owners receive an email, it is still OK.
That I'm going to test now.

Thanks - Leifoet
 
(tested a Yahoo adress without underscore) => NOK - no email received.

So, as you can now tell the 'underscore' being the cause was purely deductive reasoning based on invalid data. The secret to good testing is to never go looking for something that proves the hypothesis., because you are almost guaranteed to find it. Instead, you should look for something that will prove your idea is incorrect.


Conclusion: a yahoo address in the FROM section fails (?)
Why would the 'from' address being Yahoo be causing a problem?

If that was the case no Yahoo email user would be able to send messages to another Yahoo mail user.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
I'm still waiting for the response of server and recipient concerning FROM / TO problems on yahoo adresses. I hope to get news soon.

Meanwhile, I have another problem - I refer to my post of 20 April - above (a piece of AJAX-code)
' response.write("<table>")
do until rs.EOF
for each x in rs.Fields
' response.write("<tr><td><b>" & x.name & "</b></td>")
' response.write("<td>" & x.value & "</td></tr>")

On an input form, I will print (response.write), under an input button on the page/screen, the little table with the x.name and the x.value .
When I tray to 'response.write', this table is displayed at the top of the screen above everything = not so user friendly.

The table will be generated by a separate file => original AJAX file at W3School AJAX Database getcustomer.asp

What is the proper (ASP) code to do this?

Thanks for tips - Leifoet

 
' response.write("<table>")
do until rs.EOF
for each x in rs.Fields
' response.write("<tr><td><b>" & x.name & "</b></td>")
' response.write("<td>" & x.value & "</td></tr>")

None of that is AJAX code.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
On w3school website I read: "AJAX Database Example - The following example will demonstrate how a web page can fetch information from a database with AJAX"
Excuses if I used the words 'Ajax code' in a wrong context - English is not my native language and sometimes certain nuances can escape me.

My problem is : how can I display the little table from another file (and also from the W3School-example):
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td>" & x.value & "</td></tr>")

at any place in a web page/on the screen and no longer at the top of the page / screen ? what code ?

Thanks for tips - Leifoet

 
First off, AJAX is not a language, it is a methodology for updating information on a HTML document without requiring that the entire document be retrieved from the server. What happens on the server is nothing to do with the "AJAX" code, the two are completely separate. The HTTPRequest object 'asks' the server for the 'current' data then the returned information is displayed where it is required, the returned data may or may not contain HTML code,

In your example the returned data would be;

HTML:
<tr><td><b>some-name</b></td><td>some-value</td></tr>

So "where to display" would be "between table start and end tags.

The how is using a document.write() statement.


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
I do not understand the process very good - is it possible to explain this a little more in detail.

FORM A (or the INPUT file) => I will place the <x.name> and the <x.value> from FORM B physically under an input listbox (selection of a lastname)
Form B (or file B) (not the same as FORM A !) => AJAX database example from W3School => gives additional info (fields) on the selected lastname :
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td>" & x.value & "</td></tr>")

I converted already this result in 'session variables' but I can't 'print'/display it on a the screen.
<p><INPUT TYPE="text" SIZE="30" NAME="mail" value="<%response.write Session("mail")%>"></p>
<p><INPUT TYPE="text" SIZE="30" NAME="tmail" value="<%response.write Session("telephone")%>"></p>

My problem
(As I wrote) the <x.name> and the <x.value> are displayed at the top of the screen AND not at the place (in the screen) where it must be

How can I use e.g. document.write() to place x.name and x;value at the place that i will - what must come between the brackets ?
Where do i put some code in FORM A or FORM B or in both ?

Thanks for additional help - Leifoet
 
If you only want to get the name and value of the fields from the server you create a asp document URL on the server that ONLY returns those values, you do not make it return ANY HTML at all.

So your database extraction loop concatenates the names and values into a key/value comma separated string

<% output = output x.name &':' & x.value & ',' %>

So you then have a string (output) of key/value pairs (or 'tuples' as they are known) with a colon separating the 'key' and it's 'value' and each tuple is separated by a comma.

This string would then be streamed out to the user agent (in this case the javascript HTTTPRequest object request) using response.write

<% response.write(output) %>

then you transfer the response output which will be in requestObj.ResponseText to a javascript array

var responseArray = requestObj.ResponseText.split(","); which will get an array of key/value tuples

Then you can iterate through responseArray and split each key and value with .split(":") into individual items with the key in array[0] and the value in array[1]

Finally document.write(); the individual elements into the appropriate HTML elements of the output document.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
I try to follow.
then you transfer the response output which will be in requestObj.ResponseText to a javascript array
var responseArray = requestObj.ResponseText.split(","); which will get an array of key/value tuples

Is this my array of key/value tuples ? = from my FORM B = from the example 'getcustomer.asp' in W3Schools on
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td>" & x.value & "</td></tr>")

or (I converted already this result in 'session variables' but I can't 'print'/display it on a the screen)
<p><INPUT TYPE="text" SIZE="30" NAME="mail" value="<%response.write Session("mail")%>"></p>
<p><INPUT TYPE="text" SIZE="30" NAME="tmail" value="<%response.write Session("telephone")%>"></p>

Then you can iterate through responseArray and split each key and value with .split(":") into individual items with the key in array[0] and the value in array[1]
Finally document.write(); the individual elements into the appropriate HTML elements of the output document.

My problem is or remains the same : how to apply your (theoretical) approach in effective or practical / operative HTML code
I do not find the right code / syntax for the document.write () to put the output from my FORM B (my FORM B = the example 'getcustomer.asp' in W3Schools on into my form A :
document.write (what syntax comes betreen this brackets ?)

Thanks for help - Leifoet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top