DIVs + FORMs

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

DIVs + FORMs

Post by Illusionist »

hmm... strange question i suppose... But what i have is a form inside of a DIV. And what i want is when the submit is clicked It shows in back int he DIV. Sort of treat the DIV as Frame. If thats possible. I've looked around, but can't seem to find anythign realting to this. Anytone know of anything that might work??

Also, the form is comming from a sepereate page. I have soemthing like this:

Code: Select all

<div id="content">
<? include('myform.php'); ?>
</div>
If that helps any!!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you don't want to reload the page, you'll have to use javascript to both validate and reflow the contents of your div with something like this:

Code: Select all

<script language="Javascript"><!--

function reflowContent(formObj,newContent)
{
  if( typeof formObj == "object" && typeof newContent == "string")
    formObj.innerHTML = newContent;
}

function formSubmit(formObj,flowHere)
{
  // do your validation here.
  // if it's all good, reflow the content.
  var container = ((document.getElementById)?(document.getElementById(flowHere)):(document.all[flowHere]));
  reflowContent(container,"blah blah blah blah blah new content!");
  // because the form doesn't really submit anywhere, tell the browser to not send it.
  return false;
}

--></script>
and your php include would look something like:

Code: Select all

<form onsubmit="return formSubmit(this,'content')"><input type=text name="junk" value="junk"></form>
Post Reply