dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Help with AJAX forms

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    3

    Help with AJAX forms

    Would appreciate any help with modifying the existing AJAX here: http://javascript.internet.com/ajax/...vigation2.html

    I need to post form values to a second .ASP page (instead of clicking the text link in this provided code).

    Thanks in advance.

  2. #2
    Join Date
    May 2010
    Posts
    3

    Further ...

    I have found some code that appears to provide AJAX form functionality however it isn't working for me .. perhaps some-one could see my error? Thanks!

    index.html page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title>First and Last Name using XmlHttpRequest</title>
    <script language="javascript" type="text/javascript">
    var url = "FirstLast.asp?param="; // The server-side script
    function handleHttpResponse() {
    if (http.readyLastName == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
    // Split the comma delimited response into an array
    results = http.responseText.split(",");
    document.getElementById('FirstName').value = results[0];
    document.getElementById('LastName').value = results[1];
    isWorking = false;
    }
    }
    }
    var isWorking = false;
    function updateName() {
    if (!isWorking && http) {
    var ReservationIDValue = document.getElementById("ReservationID").value;
    http.open("GET", url + escape(ReservationIDValue), true);
    http.onreadyLastNamechange = handleHttpResponse;
    isWorking = true;
    http.send(null);
    }
    }
    function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
    xmlhttp = false;
    }
    }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (e) {
    xmlhttp = false;
    }
    }
    return xmlhttp;
    }
    var http = getHTTPObject(); // We create the HTTP Object
    </script>
    </head>
    <body>
    <form action="post">
    <p>
    ResID:
    <input type="text" size="15" name="ReservationID" id="ReservationID" onBlur="updateName();" />
    </p>
    FirstName:<input type="text" name="FirstName" id="FirstName" size="12"/>
    LastName: <input type="text" size="12" name="LastName" id="LastName" />
    </form>
    </body>
    </html>


    FirstLast.asp:

    <%@ Language=VBScript %>
    <%Option Explicit%>

    <%
    Dim conn,sql,rs,ReservationID, FirstName, LastName
    ReservationID = = $_GET['param'];

    Set conn = server.CreateObject("adodb.connection")

    SQL= "SELECT FirstName,LastName from v_ReservationReport WHERE languageid="1" and ReservationID ="& ReservationID

    conn.Open Application("strConnect")
    set rs=server.CreateObject ("adodb.recordset")
    rs.Open sql,conn,adOpenDynamic,adLockReadOnly

    FirstName = rs("FirstName")

    LastName = rs("LastName")

    Response.Write FirstName,Lastname

    rs.Close
    set rs=nothing

    conn.Close
    set conn=nothing


    %>

  3. #3
    Join Date
    May 2010
    Posts
    3

    Variation perhaps?

    I would also be able to extract the information I need if it was passed in the URL.

    So if the presented example wasn't fixable would anyone be able to provide some code for taking the form values and appending them to the URL in the javascript?

    If so could you provide the code for two or more form values to be appended upon form being submitted?

    thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles