Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Iframe won't submit in IE

Status
Not open for further replies.

tektipsismyfavorite

Technical User
May 4, 2006
57
US
I have an iframe with nothing but a form inside it and for some strange reason, the form won't submit in IE. It works fine in Firefox, but hangs in IE.
iframe:
Code:
<iframe id="info" src="moreinfo.php" frameborder="0" width="500" height="410" scrolling="no"></iframe>

form:
Code:
$submitFormAction = $_SERVER['PHP_SELF'];
//-------------------------
<form id="develop" name="develop" method="post" action="<?php echo $submitFormAction; ?>">

onclick function
Code:
function checkForm(){
	var errStr = null;
	if(document.develop.name.value == ""){
		errStr = "\nPlease enter your name.";
	}
	
	if(document.develop.email.value == ""){
		if(errStr == null){
			errStr = "\nPlease enter your email address.";
		} else {
			errStr += "\nPlease enter email address.";
		}
	}
	
	rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");
	if(document.develop.email.value != "" && !rx.test(document.develop.email.value)){
		if(errStr == null){
			errStr = "\nPlease provide a valid email address.";
		} else {
			errStr += "\nPlease provide a valid email address.";
		}
	}
	
	if(document.develop.aoe.value == ""){
		if(errStr == null){
			errStr = "\nPlease select an area of expertise.";
		} else {
			errStr += "\nPlease select an area of expertise.";
		}
	}
	
	if(document.develop.reason.value == ""){
		if(errStr == null){
			errStr = "\nPlease tell us why you want to help.";
		} else {
			errStr += "\nPlease tell us why you want to help.";
		}
	}
	
	if(errStr != null){
		alert("There were some errors:\n"+errStr);
		return false;
	} else {
		document.develop.Submit.value = "Sending...";
		document.develop.Submit.disabled = true;
		return true;
	}
}
In IE, it will still do the alert(), rename Submit, and disable it, but won't process the form.
 
Don't name your submit button "Submit" - it may cause confusion with the submit method of the form (even though the case is different).

Also, where/when is the "onclick" function being called?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
<input type="submit" name="Submit2" value="Request the Info" onclick="return checkForm();" />
 
I've tried that and it causes the function to not even work in IE. I've designed hundreds of forms with similar javascript validation code, but never in an iFrame. I'm not sure why IE is having problems with it.
 
ok, well, i got rid of the 2 lines to disable the button. it works, but button doesn't disable :(...
Code:
if(errStr == null){
	//document.develop.Submit2.value = "Sending...";
	//document.develop.Submit2.disabled = true;
	return true;
} else {
	alert("There were some errors:\n"+errStr);
	return false;
}

I just realized, I have code on my page that gets rid of the google toolbar autofill yellow background... That's probably what's screwing it up.

Code:
<body>
<script type="text/javascript">
<!--
  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }
//-->
</script>
....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top