Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

Submit not functioning right

Hello, I have a form that is flash that mirrors it's self to an html form but also sends a Post to a php.  In this case seeing the submit button is not an option for the HTML form...though the button is in the HTML form. The HTML form is set display:none not hidden, so I created a submit function from the w3school and all was well... but for some odd reason it is not working anymore... but if I take display:none off the HTML form and click the submit button it does.. and post just fine... thing is, it does the php first post via flash just fine... but when it comes to the second post via JS it's like the post data is gone or it doesn't now were it is going... Dose anyone have an idea? I'm sure I'm just over looking something... or if it is that the post is empty, I just need to figure out how to full it again before flash call the JS that submits that form... Thanks for the help... hope to hear back soon cause Im finding nothing... and I was on a roll :) but this happens..

this is the landing page text
Internet Explorer cannot display the webpage

the HTML
<form id="m7moduleform_2" method="post" action="index.php" enctype="multipart/form-data"><div class="hidden"><input type="hidden" name="mact" value="FrontEndUsers,m7,do_userchangesettings,1" /><input type="hidden" name="m7returnid" value="93" /><input type="hidden" name="page" value="93" /></div>
<input type="hidden" name="m7feu_hidden_username" value="username;0;30;3" />
<font color="blue">Username*</font>
              <input type="text" name="m7feu_input_username" id="m7feu_input_username" value="TestAPP" size="20" maxlength="20" disabled="disabled" />
 <input type="hidden" name="m7feu_input_returnto" value="interactive-job-application" />
<input name="m7feu_submit" value="Submit" type="submit" />
<input name="m7feu_cancel" value="Cancel" type="submit" />

</form>
//////////////the JS
function formSubmit()  {   
alert("submiting now");
var x=document.getElementById("m7moduleform_2")
x.action="index.php"
x.enctype="multipart/form-data"
x.method="post"
x.submit()
 }
 
 
 
////////////////////////the AS
Bar.Send.onRelease = function() {
	var FullArray:String = "{name:value}";
	for (var i = 0; i<fieldArray.length; i++) {
		switch (fieldArray[i].type) {
			case "textInput" :
				fieldArray[i].mc.addEventListener("change",onSelect_text);
				var pos = testIfSelected(this._name);
				outPutArray.splice(pos,1);
				if (pos == -1) {
					outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.text);
				}
				FullArray = FullArray+",{"+outPutArray+"}";
				//trace(outPutArray);
				clickSend();
				break;
			case "checkBox" :
				fieldArray[i].mc.addEventListener("click",onSelected);
				var pos = testIfSelected(this._name);
				if (fieldArray[i].mc.selected == true) {
					outPutArray.splice(pos,1);
					if (pos == -1) {
						outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.label);
					}
					FullArray = FullArray+",{"+outPutArray+"}";
					trace(outPutArray);
				} else if (fieldArray[i].mc.selected == false) {
					outPutArray.splice(pos,1);
					if (pos == -1) {
						outPutArray.push(fieldArray[i].mc._name+":na");
					}
					FullArray = FullArray+",{"+outPutArray+"}";
					//trace(outPutArray);
				} else {
					if (pos>=0) {
						outPutArray.splice(pos,1);
					}
					FullArray = FullArray+",{"+outPutArray+"}";
					//trace(outPutArray);
				}
				clickSend();
				break;
			case "comboBox" :
				fieldArray[i].mc.addEventListener("change",onSelect_cbItemPicked);
				var pos = testIfSelected(this._name);
				outPutArray.splice(pos,1);
				if (pos == -1) {
					outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.selectedItem.data);
				}
				FullArray = FullArray+",{"+outPutArray+"}";
				//trace(outPutArray);
				clickSend();
				break;
			case "Date" :
				fieldArray[i].mc.addEventListener("change",onSelect_Date);
 
				var pos = testIfSelected(this._name);
				outPutArray.splice(pos,1);
				if (pos == -1) {
					outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.selectedDate);
				}
				FullArray = FullArray+",{"+outPutArray+"}";
				//trace(outPutArray);
				clickSend();
				break;
			case "YES_NO" :
				var ya:Object = null;
				var na:Object = null;
				body = fieldArray[i].mc._name;
 
				var NStage1 = strip_Y(body);
				var FINResult = strip_N(NStage1);
 
 
				ya = FINResult+"_Y";
				na = FINResult+"_N";
				fieldArray[i].mc.addEventListener("click",onSelectedPath);
				if (fieldArray[i].mc.selected == true) {
					if (fieldArray[i].mc._name == ya) {
						outPutArray.splice(pos,1);
						if (pos == -1) {
							outPutArray.push(fieldArray[i].mc._name+":Yes");
						}
						FullArray = FullArray+",{"+outPutArray+"}";
						//trace(outPutArray);
						clickSend();
					} else {
						outPutArray.splice(pos,1);
						if (pos == -1) {
							outPutArray.push(fieldArray[i].mc._name+":No");
						}
						FullArray = FullArray+",{"+outPutArray+"}";
						//trace(outPutArray);
						clickSend();
 
					}
				} else {
 
				}
				break;
		}
	}
	//trace(FullArray);
	
	
	
	
	/*var emailResponse:LoadVars = new LoadVars();
    emailResponse.onLoad = function(success:Boolean) {
    if (success) {
            debug_txt.text = this.result;
				ExternalInterface.call("formSubmit");
	trace("Submited");
	trace(postVars.dataArray);
    } else {
            debug_txt.text = "error downloading content";
    }
    };*/
 
 var postVars:LoadVars = new LoadVars();
    postVars.dataArray = FullArray;
    postVars.sendAndLoad("../Core_files/PDFgenerator/tcpdf_php4/examples/example_011.php", dataReceiver, "POST");
 
	
 
	
};	
	dataSender = new LoadVars();
	dataReceiver = new LoadVars();
	dataReceiver.onLoad = function() {
   if (this.response == "invalid") {
      alert_txt.text = "Please check from."
   } else if (this.response == "error") {
      alert_txt.text = "Please check from."
   } else if (this.response == "passed") {
	   alert_txt.text = "Please check from."
      ExternalInterface.call("formSubmit");
   }
}
 
 
function clickSend(eventObj:Object):Void {
	var jsArgument:String = outPutArray;
	var result:Object = ExternalInterface.call("getTextFromFlash", jsArgument);
	ObjectToPass = "m7feu_input_"+result;
	trace("sent");
}
onEnterFrame(load);
{
	var FullArray:String = "{name:value}";
	//_global.FullArray = new Array();
	_global.outPutArray = new Array();
	_global.testIfSelected = function(t) {
		for (i=0; i<outPutArray.length; i++) {
			if (outPutArray[i] == t) {
				return i;
			}
		}
		return -1;
	};
};

Open in new window

0
jeremyBass26
Asked:
jeremyBass26
  • 7
  • 3
1 Solution
 
afzzCommented:
try this
function formSubmit()  {   
//alert("submiting now");
var x=document.getElementById("m7moduleform_2");
x.action="index.php";
x.enctype="multipart/form-data";
x.method="post";
x.submit();
 }

Open in new window

0
 
jeremyBass26Author Commented:
Nope.... alothought it still "works" in the sense that it is submiting... but i'm still getting "Internet Explorer cannot display the webpage".... heck that fact that it comes up that way confuses me... yes it's posting to index.php but it is a cms and all goes to index.php... it's more like the post data is empty or the  type="hidden"  are not being respected... I'm at a loose on this.... I hope someone here can spot it...
0
 
jeremyBass26Author Commented:
I have it for sure that it's something with posting the data from flash to php and not haveing the data or an empty post or somthing...

I change
to
function formSubmit()  {  
alert("submiting now");
//var x=document.getElementById("m7moduleform_2");
//x.action="index.php";
//x.enctype="multipart/form-data";
//x.method="post";
//x.submit();
 }
and used the button on the form and it did the same thing of landing on the index.php and "Internet Explorer cannot display the webpage" where as if i just run through the form and click the submit button it does pass the post data and redirects back to the page like it is sapose to do...


we is this occuring and how does one work around it... ?

in this post
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23447583.html
we talked about posting on html form tto two php scripts... but i by passed that by post out of flash... but it seems that I may ned to do something like this, but much lighter as there is 200 fields... and it's heavy now...



example:
<tr>
     <td><input type="hidden" name="m7feu_hidden_`em_his_address" value="`em_his_address;0;30;1;" />
<font color="">`em_his_address</font></td>
     <td>
              <input type="text" name="m7feu_input_`em_his_address" id="m7feu_input_`em_his_address" value="" size="30" maxlength="255"  class="`em_his_address" />

                            </td>
  </tr>


All JS in play
//////At the bottom under the form
 
{literal}
<script type="text/javascript">
var formFIELDS = new Array ();
var x= document.getElementById("m7moduleform_2");
for (var i=0;i<x.length;i++)
{	
formFIELDS.push(x.elements[i].id);
}</script>{/literal}
 
 
///////in the head
 
{literal}
<script type="text/javascript">
	function SetHTML1(type) {
		document.getElementById("a3").style.display = "none"
		document.getElementById("b3").style.display = "none"
		document.getElementById("c3").style.display = "none"
		// Using style.display="block" instead of style.display="" leaves a carriage return
		document.getElementById(type).style.display = ""
	}
</script>
 
 
 
 
 
 
 
<script language="JavaScript">
<!--
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}
 
 
function formSubmit()  {   
alert("submiting now");
//var x=document.getElementById("m7moduleform_2");
//x.action="index.php";
//x.enctype="multipart/form-data";
//x.method="post";
//x.submit();
 }
 
 
 
function formSend() {
alert('formSend()');
var text = document.htmlForm.sendField.value;
getFlashMovie("v2.l").sendTextToFlash(ObjectToPass);
 
}
 
 
 
//var formFIELDS = new Array  looks like ("m7feu_input_`rotate_shifts","m7feu_input_`Weekends","m7feu_input_`test","m7feu_input_`comboBox","m7feu_input_`datagrid","m7feu_input_`date","m7feu_input_`text","m7feu_input_`textarea");
 
 
 
	
function getTextFromFlash(str) {
///////splits the strings
	var formFIELDSname = new Array ();		
	for(i = 0 ; i <formFIELDS.length;  i++){
		var mySplitFormFIELDSResult = formFIELDS[i].split("`");		
		formFIELDSname.push(mySplitFormFIELDSResult[1]);
	}
	//alert(formFIELDSname);
	for(i = 0 ; i <formFIELDSname.length;  i++){
		//alert('FIELDS name to check against and for placement:::: '+formFIELDSname[i]);
	}
	var myString = str;
	for(i = 0 ; i <myString.length;  i++){
	var mySplitResult = myString[i].split(":");
	}
//// needs to strip _Y or _N if exist in string from mySplitResult
	var patternA = new RegExp("_Y$");
	var patternB = new RegExp("_N$");
	new_mySplitResult = mySplitResult[0].replace(patternA, "");
	FINResult = new_mySplitResult.replace(patternB, "");
	//alert('FINResult::' + FINResult);
 
//// push FINResult to formFIELDS were FINResult[0] == formFIELDSname[1]
 
	//alert('test2::::' + mySplitResult);
	//alert('test for value placment::::' + FINResult);
	//alert('Value wanted::::' + mySplitResult[1]);	
	for(i = 0 ; i <formFIELDSname.length;  i++){
			if (FINResult == formFIELDSname[i]) {
				//alert('Field and Value::::'+FINResult+'::::'+ mySplitResult[1]);
				document.getElementById('m7feu_input_`'+FINResult).value = mySplitResult[1];
 
			}
	}
 
}
 //-->
</script>{/literal}

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jeremyBass26Author Commented:
no one has an Idea?
0
 
jeremyBass26Author Commented:
Still no one knows how to do this?  Please i really need some help on this... is it a code syntax thing? or what? well an FYI... I will be out after 4pm PST and will be gone for my son's surgery for the next four days... so I will not be able to do much if any thing...
thanks again...
jeremyBass
0
 
TeRReFCommented:
I would try it somewhat different. Remove the display:none from the submit button, and position it at -100, -100 with a position absolute. SOmething like:
position: absolute; top: -100px; left: -100px;

Then to submit in the JS script, just find the submit button with a getElementById:
$subm = getElementById("submitbuttonid");
$subm.submit();
0
 
TeRReFCommented:
PS. I hope everything went well with your son's surgery...
0
 
jeremyBass26Author Commented:
Hello, thanks for the good thought, we'll be off and out of here in an hour... :) well to, at hand... I'm not seeing how your solution would fix it, as before it did save while as display:none... I'll check on this when i get back but Im like 99% sure it was submitting fine before... It's Just that now it's not... yeah, fun stuff lol... I'm 90% sure that the post data is being wiped out? Ok more like 60% sure but still... it worked great before i had to post this to a php script... any ideas?   Well have a great day... Im off for a while now... :)

jeremyBass
0
 
TeRReFCommented:
Well, you can test it in the php script by adding this line just below the <?php line:

print_r($_POST);

or if you want to make sure the values aren't passed via GET you can also try:

print_r($_REQUEST);

since $_REQUEST holds both the $_GET and $_POST values...
0
 
jeremyBass26Author Commented:
I'm sorry, I thought I had said this but it looks like I may have over looked it... The post does get to php script... and the script runs and sends back to flash passed...

/////////////////////////////////////////////the receive function in flash
dataReceiver = new LoadVars();
      dataReceiver.onLoad = function() {
   if (this.response == "invalid") {
      alert_txt.text = "Please check from."
   } else if (this.response == "error") {
      alert_txt.text = "Please check from."
   } else if (this.response == "passed") {
         alert_txt.text = "Please check from."
      ExternalInterface.call("formSubmit");
   }
}
////////////////////////////

so as you can see after a successful running of the php(which does account for the post being there) flash then gets triggered to call a JS function (   ExternalInterface.call("formSubmit"); ) which also runs, but it this point the post data the comes from the html form does not work... ... it so seems... hope that make sense... I can't test anything as Im 200miles from my computer at some hospital...  thanks for the help on this... have a great one...
0
 
jeremyBass26Author Commented:
Ok the trick was

function formSubmit()  {  
alert("submiting now");
document.getElementById("m7moduleform_2").submit();
 }

instead of

function formSubmit()  {  
alert("submiting now");
var x=document.getElementById("m7moduleform_2");
x.action="index.php";
x.enctype="multipart/form-data";
x.method="post";
x.submit();
}

And removing the writing to the HTML form in one set.... this opens up a new issue... so I solved this... but Im going to have a new issues all together.. But the saving grace is that it is a smaller issue...


Sure wish I had more lookers on this one... the solution was simple... but just an illusive one... thanks to those who tried... have a great one... and Ill have a new question on the small issue later... need to move on to one of the last main functional issues...

jeremyBass



the complete refactored AS (has all functions that was expanded but does not have a play in this issue)
function clickSend(eventObj:Object):Void {
	var jsArgument:String = outPutArray;
	var result:Object = ExternalInterface.call("getTextFromFlash", jsArgument);
	ObjectToPass = "m7feu_input_"+result;
	trace("sent");
}
function phpSend(eventObj:Object):Void {
//	var jsArgument:String = complete_outPutArray;
//	var result:Object = ExternalInterface.call("getTextFromFlash", jsArgument);
//	ObjectToPass = "m7feu_input_"+result;
	trace("sent");
}
onEnterFrame(load);
{
	var FullArray:String = "{name:value}";
	//_global.FullArray = new Array();
	_global.complete_outPutArray = new Array();
	_global.outPutArray = new Array();
	_global.testIfSelected = function(t) {
		for (i=0; i<complete_outPutArray.length; i++) {
			if (complete_outPutArray[i] == t) {
				return i;
			}
		}
		return -1;
	};
};
 
function submitTo() {
	var FullArray:String = "{name:value}";
	var myDate:Date = new Date();
	FullArray = FullArray+",{Applacation Date:"+myDate+"}";
	PG_8.emps_grd.multipleSelection = true;
	PG_8.emps_grd.selectedIndices = [0, 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];
	var s:String = "";
	var myObjArray:Array = PG_8.emps_grd.selectedItems;
	var i = 0;
	for (i=0; i<myObjArray.length-1; i++) {
		s = s+"{row|"+i+",employer|"+myObjArray[i].Employer+",address|"+myObjArray[i].Address+",phone|"+myObjArray[i].Phone+",supervisor|"+myObjArray[i].Supervisor+",contact|"+myObjArray[i].Contact+",wage|"+myObjArray[i].Wage+",duties|"+myObjArray[i].Duties+",from|"+myObjArray[i].From+",to|"+myObjArray[i].To+",reason|"+myObjArray[i].Reason+"},";
	}
	// add the last one without a comma on the end
	i = myObjArray.length-1;
	s = s+"{row|"+i+",employer|"+myObjArray[i].Employer+",address|"+myObjArray[i].Address+",phone|"+myObjArray[i].Phone+",supervisor|"+myObjArray[i].Supervisor+",contact|"+myObjArray[i].Contact+",wage|"+myObjArray[i].Wage+",duties|"+myObjArray[i].Duties+",from|"+myObjArray[i].From+",to|"+myObjArray[i].To+",reason|"+myObjArray[i].Reason+"}";
	var pos = testIfSelected(this._name);
	complete_outPutArray.splice(pos,1);
	if (pos == -1) {
		complete_outPutArray.push(PG_8.emps_grd._name+":"+s);
	}
	FullArray = FullArray+",{"+complete_outPutArray+"}";
	trace(complete_outPutArray);
	phpSend();
	
	var s:String = "";
	var myObjArray:Array = Starts.jobs_picks.selectedItems;
	var i = 0;
	for (i=0; i<myObjArray.length-1; i++) {
		s = s+"{Job_Pick`"+i+"|"+myObjArray[i].label+"},";
	}
	// add the last one without a comma on the end
	i = myObjArray.length-1;
	s = s+"{Job_Pick`"+i+"|"+myObjArray[i].label+"}";
 
	var pos = testIfSelected(this._name);
	complete_outPutArray.splice(pos,1);
	if (pos == -1) {
		complete_outPutArray.push(Starts.jobs_picks._name+":"+s);
	}
	FullArray = FullArray+",{"+complete_outPutArray+"}";
	trace(complete_outPutArray);
	phpSend();
	
	for (var i = 0; i<fieldArray.length; i++) {
		
		switch (fieldArray[i].type) {
			case "textInput" :
				fieldArray[i].mc.addEventListener("change",onSelect_text);
				var pos = testIfSelected(this._name);
				complete_outPutArray.splice(pos,1);
				if (pos == -1) {
					complete_outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.text);
				}
				FullArray = FullArray+",{"+complete_outPutArray+"}";
				trace(complete_outPutArray);
				phpSend();
				break;
			case "checkBox" :
				fieldArray[i].mc.addEventListener("click",onSelected);
				var pos = testIfSelected(this._name);
				if (fieldArray[i].mc.selected == true) {
					complete_outPutArray.splice(pos,1);
					if (pos == -1) {
						complete_outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.label);
					}
					FullArray = FullArray+",{"+complete_outPutArray+"}";
					trace(complete_outPutArray);
				} else if (fieldArray[i].mc.selected == false) {
					complete_outPutArray.splice(pos,1);
					if (pos == -1) {
						complete_outPutArray.push(fieldArray[i].mc._name+":");
					}
					FullArray = FullArray+",{"+complete_outPutArray+"}";
					trace(complete_outPutArray);
				} else {
					if (pos>=0) {
						complete_outPutArray.splice(pos,1);
					}
					FullArray = FullArray+",{"+complete_outPutArray+"}";
					trace(complete_outPutArray);
				}
				phpSend();
				break;
			case "comboBox" :
				fieldArray[i].mc.addEventListener("change",onSelect_cbItemPicked);
				var pos = testIfSelected(this._name);
				complete_outPutArray.splice(pos,1);
				if (pos == -1) {
					complete_outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.selectedItem.data);
				}
				FullArray = FullArray+",{"+complete_outPutArray+"}";
				trace(complete_outPutArray);
				phpSend();
				break;
			case "Date" :
				fieldArray[i].mc.addEventListener("change",onSelect_Date);
 
				var pos = testIfSelected(this._name);
				complete_outPutArray.splice(pos,1);
				if (pos == -1) {
					complete_outPutArray.push(fieldArray[i].mc._name+":"+fieldArray[i].mc.selectedDate);
				}
				FullArray = FullArray+",{"+complete_outPutArray+"}";
				trace(complete_outPutArray);
				phpSend();
				break;
			case "checkBoxYN" :
				fieldArray[i].chkYes.addEventListener("click",checkBoxListener);
				fieldArray[i].chkNo.addEventListener("click",checkBoxListener);
				if (fieldArray[i].chkYes.selected == true) {
					var pos = testIfSelected(fieldArray[i].chkYes._name);
					complete_outPutArray.splice(pos,1);
					if (pos == -1) {
						complete_outPutArray.push(fieldArray[i].chkYes._name+":"+"Yes");
					}
					FullArray = FullArray+",{"+complete_outPutArray+"}";
					trace(complete_outPutArray);
					//trace(fieldArray[i].chkYes._name+":Yes");
					phpSend();
				} else if (fieldArray[i].chkNo.selected == true) {
					var pos = testIfSelected(fieldArray[i].chkNo._name);
					complete_outPutArray.splice(pos,1);
					if (pos == -1) {
						complete_outPutArray.push(fieldArray[i].chkNo._name+":"+"No");
					}
					FullArray = FullArray+",{"+complete_outPutArray+"}";
					//trace(fieldArray[i].chkNo._name+":No");
					trace(complete_outPutArray);
					phpSend();
				} else {
					var pos = testIfSelected(fieldArray[i].chkNo._name);
					complete_outPutArray.splice(pos,1);
					if (pos == -1) {
						complete_outPutArray.push(fieldArray[i].chkNo._name+":"+"");
					}
					FullArray = FullArray+",{"+complete_outPutArray+"}";
					trace(fieldArray[i].chkNo._name+":"+"");
				}
				break;
		}
		
	}
	trace(FullArray);
 
}
 
 
 
 
 
 
 
 
 
 
 
 
//////////////////
/// on submit
//////////////////
Bar.Send.onRelease = function() {
	submitTo();
	var postVars:LoadVars = new LoadVars();
	postVars.dataArray = FullArray;
	postVars.sendAndLoad("../Core_files/PDFgenerator/tcpdf_php4/examples/example_011.php",dataReceiver,"POST");
};

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now