[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

AJAX :: trying to make a form from form results

Asked by stu215 in Asynchronous Javascript and XML (AJAX), JavaScript, Cold Fusion Markup Language

Tags: AJAX, SPRY, CFM, Javascript

I have a form which is inside a spry tabbed panel which when submitted returns a list of personnel.

Each personnel has a link / form associated with their name.

When I click on a name it should bring up detail on the employee.
-- The results of that form dont seem to work [ need help :-( ]
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
<!--- START AJAX Form Processing --->
<script type="text/javascript" language="javascript">
   var http_request = false;
   function makeRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url + parameters, true);
      http_request.send(null);
   }
 
   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj, myFile) {
      var getstr = "?";
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "text") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }
      makeRequest(myFile, getstr);
   }
</script>
 
<!--- END AJAX Form Processing --->
 
<!--- My FORM 1 / page1--->
	<form name="getLabs" action="javascript:get(document.getElementById('myLabs'), 'viewLab.cfm');" id="myLabs" target="_parent">
	<tr>
    	<td><b>Select a Lab to view ::</b></td>
    	<td>
			<cfoutput>
            <select name="empID">
                <cfloop from="1" to="#getPI_List.recordcount#" index="f">
                    <option value="#getPI_List.Emp_ID_Sys[f]#">#getPI_List.Last_Name[f]#, #getPI_List.First_Name[f]#</option>
                </cfloop>
            </select>
            </cfoutput>
        </td>
    	<td>
        	<input type="submit" name="Search" value="Search" />
        </td>
    </tr>
	</form>
<br />
 
<span name="myspan" id="myspan"></span>
<!--- END FORM 1 / page1 --->
 
<!--- FORM 2 / page2 --->
 
<table width="800" border="0">
<cfloop from="1" to="#getReqTraining.recordcount#" index="k">
    <tr>
    	<td>
           <a href="X" onClick="document.udEmp#getEmp_List.Emp_ID_Sys[j]#.submit();return false;">#getEmp_List.First_Name[j]#&nbsp;#getEmp_List.Last_Name[j]#</a>
         </td>
    </tr>
    <form name="udEmp#getEmp_List.Emp_ID_Sys[j]#" action="javascript:get(document.getElementById('myEmps'), 'udEmployee.cfm');" id="myEmps">
       <input type="hidden" name="myName" value="#getEmp_List.First_Name[j]# #getEmp_List.Last_Name[j]#">
      <input type="hidden" name="Emp_ID" value="#getEmp_List.Emp_ID[j]#">
     </form>
</cfloop
</table>
 
<!--- END FORM 2 / page2 --->
 
<!--- FORM 3 / page3 --->
 
      I cant seem to receive any form variables on this page from form 2
which calls it.
 
     Variables i need :: myName; Emp_ID
 
<!--- END FORM 3 / page3 --->
[+][-]04/09/09 04:35 AM, ID: 24106135Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/09/09 07:46 AM, ID: 24107698Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/09/09 08:02 AM, ID: 24107838Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_EXPERT_20070906