SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    capture value from window.prompt alert, use as variable in asp

    hi

    i have an asp page, i am trying to capture an email address using a window alert and use it as the recipient.

    the code is below, the message alert is not appearing and also im not sure if i am using the value correctly.

    would appreciate some help

    thanks



    Code:
    <!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></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head> 
    
    <body>
    
    <script type="text/javascript">
    var uremail=window.prompt("Please enter your email address:")
    </script>
    
    <% 
    
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject= "London Heathrow Cars - Email Quote"
    myMail.From="me@gmail.com"
    myMail.To= uremail
    
    
    HTMLBody = "my html email"
    
    myMail.HTMLBody = HTMLBody
    myMail.Send
    
    set myMail=Nothing
    %>
    
    </body>
    
    </html>

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i am gettin somewhere, the prompt loads but it doesnt get used as the email recipient, also im confused as to how i can grab the email address and then instantly redirect without the page having to display as blank.


    my code is below, you can see this in action by going to the link below. scroll to the very bottom of the page and click send.

    http://www.londonheathrowcars.com/fr...1&myplace=P365

    Code:
    <&#37;
    
    Set myMail=CreateObject("CDO.Message")
    
    HTMLBody = "my html email"
    
    
    %>
    
    <!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></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script language=javascript>
    function load()
    {
    var useremail = prompt("Please enter your email address:");
    document.myform.emailbox.value = useremail;
    }
    </script>
    
    </head>
    
    
    
    <body onload="load()">
    <form name="myform">
    <input type="text" name="emailbox" id="emailbox" />
    </form>
    
    <%
    myMail.Subject= "London Heathrow Cars - Email Quote"
    myMail.From="antonyx@gmail.com"
    myMail.To=useremail
    
    myMail.HTMLBody = HTMLBody
    myMail.Send
    
    set myMail=Nothing
    %>
    
    </body>
    
    
    
    </html>

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <!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></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script language=javascript>
    function load()
    {
    var useremail = prompt("Please enter your email address:");
    document.myform.emailbox.value = useremail;
    }
    </script>
    
    </head>
    
    
    
    <body onload="load()">
    
    
    <form name="myform">
    <input type="text" name="emailbox" id="emailbox" />
    </form>
    
    <&#37;
    
    aspvariable=request.form("emailbox")
    
    response.write ("hello " & aspvariable & "guinea pig")
    
    %>
    
    
    </body>
    
    
    
    </html>
    is this any closer?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    The asp code is run before the page gets sent to the client. You may need to ask further about this on an asp forum.
    http://www.sitepoint.com/forums/forumdisplay.php?f=148
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •