jeremyBass26
asked on
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-da ta"><div class="hidden"><input type="hidden" name="mact" value="FrontEndUsers,m7,do _userchang esettings, 1" /><input type="hidden" name="m7returnid" value="93" /><input type="hidden" name="page" value="93" /></div>
<input type="hidden" name="m7feu_hidden_usernam e" value="username;0;30;3" />
<font color="blue">Username*</fo nt>
<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-app lication" />
<input name="m7feu_submit" value="Submit" type="submit" />
<input name="m7feu_cancel" value="Cancel" type="submit" />
</form>
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-da
<input type="hidden" name="m7feu_hidden_usernam
<font color="blue">Username*</fo
<input type="text" name="m7feu_input_username
<input type="hidden" name="m7feu_input_returnto
<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;
};
};
ASKER
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...
ASKER
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( "m7modulef orm_2");
//x.action="index.php";
//x.enctype="multipart/for m-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
https://www.experts-exchange.com/questions/23447583/Submit-function.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;3 0;1;" />
<font color="">`em_his_address</ font></td>
<td>
<input type="text" name="m7feu_input_`em_his_ address" id="m7feu_input_`em_his_ad dress" value="" size="30" maxlength="255" class="`em_his_address" />
</td>
</tr>
All JS in play
I change
to
function formSubmit() {
alert("submiting now");
//var x=document.getElementById(
//x.action="index.php";
//x.enctype="multipart/for
//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
https://www.experts-exchange.com/questions/23447583/Submit-function.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
<font color="">`em_his_address</
<td>
<input type="text" name="m7feu_input_`em_his_
</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}
ASKER
no one has an Idea?
ASKER
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
thanks again...
jeremyBass
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("submitbutt onid");
$subm.submit();
position: absolute; top: -100px; left: -100px;
Then to submit in the JS script, just find the submit button with a getElementById:
$subm = getElementById("submitbutt
$subm.submit();
PS. I hope everything went well with your son's surgery...
ASKER
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
jeremyBass
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...
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...
ASKER
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...
////////////////////////// ////////// /////////t he 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("fo rmSubmit") ;
}
}
////////////////////////// //
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("fo rmSubmit") ; ) 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...
//////////////////////////
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("fo
}
}
//////////////////////////
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("fo
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Open in new window