Posting form that has ajax generated data -not posting

Posted on 2013-01-26
Last Modified: 2013-01-27
I have a form that loads a select populated with a list of teacher names.  When the teacher name is selected a series of checkboxes are loaded with regions.  A teacher can have multiple regions.  The data is then submitted...but the ajax generated data is not transmitting.  How do I do this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<title>Admin Teachers</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<meta name="robots" content="noindex,nofollow" >
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<link rel="stylesheet" href="style.css" type="text/css"  >
<link rel="stylesheet" href="pagestyle.css" type="text/css"  >
<script src=""></script>
$(document).ready(function() {
    $("#content div").hide(); // Initially hide all content
    $("#tabs li:first").attr("id","current"); // Activate first tab
    $("#content div:first").fadeIn(); // Show first tab content
    $('#tabs a').click(function(e) {
        if ($(this).closest("li").attr("id") == "current"){ //detection for current tab
        $("#content div").hide(); //Hide all content
        $("#tabs li").attr("id",""); //Reset id's
        $(this).parent().attr("id","current"); // Activate this
        $('#' + $(this).attr('name')).fadeIn(); // Show content for current tab
function getTeacherRegions(str)
if (str=="")
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if (xmlhttp.readyState==4 && xmlhttp.status==200)


<ul id="tabs">
<li><a href="#" name="tab3">Teachers</a></li>
    <li><a href="#" name="tab1">Website Pages</a></li>
    <li><a href="#" name="tab2">Students</a></li>
    <li><a href="#" name="tab4">Resources</a></li>    
     <li><a href="#" name="tab5">On Hold</a></li>  
     <li><a href="#" name="tab6">Royalties</a></li>
      <li><a href="#" name="tab7">Courses</a></li>
       <li><a href="#" name="tab8">Misc Admin</a></li>  

<div id="content">

<div id="tab3">
 <p><!--#include file="teachers_toplinks.html"--></p>
        <h2>Edit Teaching Regions</h2>
 <p><%response.write TheMessage%>&nbsp;</br> </p>        
<form method="POST" action="A2edit_teachingregions_2db.asp" style="text-align: center"  name="form1"  >

<table style="border-color: #BBDDFF" cellspacing="0" cellpadding="0" width="700">


<tr><td style="vertical-align: middle; border-color: #BBDDFF" height="30">Teacher Name</td>
<td style="vertical-align: middle; border-color: #BBDDFF" height="30">

<select name="teacher_id" id="teacher_id" onchange="getTeacherRegions(this.value);"  >
<option value="">Select a Teacher</option>

                              <%dim objC2,strC2
                              strC2="SELECT teachers.teacher_id,teachers.teacher_first_name,teachers.teacher_last_name FROM teachers,teacher_info where teacher_info.teacher_id=teachers.teacher_id and teacher_info.status='A' order by teachers.teacher_first_name"
                              set objC2=Server.CreateObject("ADODB.Recordset")
                     strC2, objConn
                              while not objC2.eof
                                    <option value="<%response.write objC2("teacher_id")%>"><%response.write objC2("teacher_first_name")&" "&objC2("teacher_last_name")%></option>
                              set objC2=nothing
                              </select> <br>

<tr><td colspan="2"> <p id="txtHint"><b>Region info will be listed here.</b></p></td></tr>
 <tr><td style="text-align: center; vertical-align: middle; border-color: #BBDDFF" height="30" colspan="2">
    <input type="button" name="submit" value="submit"  />      
</form> </p>
    <div id="tab1">
    <h2>Web Pages</h2>  
 <p><!--#include file="webpages_toplinks.html"--></p>

<div id="tab2">
   <p>Under Construction</p>  
<div id="tab4">
  <p>Under Construction</p>  
    <div id="tab5">
    <h2>On Hold</h2>
    <p>Under Construction</p>    
    <div id="tab6">
    <p>Under Construction</p>    
    <div id="tab7">
    <p>Under Construction</p>    
    <div id="tab8">
    <p>Under Construction</h3>


<!--#include virtual=""-->
<!--#include file="databaseconnect.asp"-->


dim region_id,objREG,strREG,region,numberofboxes
dim  objREG2,strREG2,count

'strREG2="SELECT * from regions where region_id IN (SELECT region_id from teachers_regions where teacher_id='"&teacher_id&"' )"
strREG="SELECT regions.region_id,regions.region from regions,teachers_regions where teachers_regions.teacher_id='"&teacher_id&"' and teachers_regions.region_id=regions.region_id"

set objREG = Server.CreateObject("ADODB.Recordset") strREG, objConn      

while not objREG.eof
      <input type="checkbox" name="<%response.write "regionF"&count%>" value="<%=region_id%>" checked>&nbsp;&nbsp;&nbsp;<%response.write region%><br>
strREG2="SELECT * from regions where region_id NOT IN (SELECT region_id from teachers_regions where teacher_id='"&teacher_id&"' )"

set objREG2 = Server.CreateObject("ADODB.Recordset") strREG2, objConn      

while not objREG2.eof
      <input type="checkbox" name="<%response.write "regionF"&count%>" value="<%=region_id%>"  >&nbsp;&nbsp;&nbsp;<%response.write region%><br>

<input type="hidden" name="numberofboxes" value="<%=numberofboxes%>">
<%'response.write numberofboxes

 <% Option Explicit %>
<!--#include virtual=""-->
<!--#include file="databaseconnect.asp"-->
<!--#include file="A2adminheader.asp"-->

<!--#include file="ErrorHandling.asp"-->

' Turn on page buffering
 Response.Buffer = True
 ' Turn On Error Handling
 On Error Resume Next
'delete all records in teachers_regions for this teacher
dim objDelete,strDelete,i,teacher_id

response.write teacher_id
response.write "<br/>"

objConn.execute "Delete from teachers_regions WHERE teacher_id='"&teacher_id&"'"

Dim numberofboxes
numberofboxes= request("numberofboxes")
dim objC4,strC4
       'step through the regions and post to teachers_regions
       for i=1 to numberofboxes
             response.write i
             response.write "<br/>"
             response.write region_id
             if region_id=1 then
                   strC4="Insert into teachers_regions (teacher_id,region_id) VALUES ('"&teacher_id&"','"&region_id&"')"
                   response.write strC4
                   response.write "<br/>"
                  Set objC4 = Server.CreateObject("ADODB.Recordset")
                  objC4.Open  strC4, objConn
                   If Err.number <> 0 then
                        TrapError Err.description
                        ErrorMessage="An Error Has occured in the regions database insert"
                        response.redirect "webpage_error.asp?ErrorMessage='"&ErrorMessage&"' "
                  End If
             end if

response.redirect "A2edit_teachingregions.asp"

Question by:vmoore99
1 Comment
LVL 11

Accepted Solution

mcnute earned 415 total points
ID: 38824144
Check first if it has been loaded when a teacher has been selected by printing it out in the console like so:


Open in new window

This will give you certainty it the data is there. The console works in firebug(firefox developer plugin and in google chrome developer tools)

Next step look if the data has been written in the fields you're submitting afterwards.

And then tell us what happened if that didn't lead to a solution.

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

There is basically two types of AJAX request in mootools. Request  and Request.HTML Request: Request is the basic XHR request class in MooTools. While not extremely useful on its own, it provides the basic functionality for both Request.HTM…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now