TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-15-2009, 04:00 PM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application Display form result in same div

Good day to you all,
I'm working on a form which would display the result in the same div that the form is.

Here is my code so far:

PHP Code:


      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
         <textarea name="html"></textarea><br />
         <input type="submit" onclick="load('<?php echo $_SERVER['PHP_SELF']; ?>','page');"/><br />
      </form>


      Preview:<br />
      <?php if(isset($_POST['html'])) echo stripslashes($_POST['html']); ?>



<script type="text/javascript">
function ahah(url, target) {
  document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
    ahah(name,div);
    return false;
}



</script>

My problem is when I click on the button , the text in my text area don't show.

Can somebody help me.

Thanks!
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form to submit to another form patmagpantay General 8 07-21-2008 07:42 AM
Display Itesm From Form? Randy Absolute Beginners 3 04-27-2008 06:29 PM
Menu Display Problem in IE6+ obolus XHTML, HTML, CSS 14 03-01-2008 07:57 PM
Contact Us Form Mohamad Script Giveaway 4 10-03-2007 02:22 PM
Form Processing William Tips & Tricks 8 04-17-2005 03:24 PM


All times are GMT. The time now is 01:52 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design