RE: [PHP] PHP-JavaScript

From: Date: Mon, 21 Jan 2002 00:41:35 +0000
Subject: RE: [PHP] PHP-JavaScript
Groups: php.general 
Request: Send a blank email to php-general+get-81301@lists.php.net to get a copy of this message
Hi, A little trick I did to get the text from a textbox in a form ( for user comments ) without the user having to submit it was to use javascript to append the textbox contents to a url ( GET METHOD ) when the user clicked on a link, which pointed to a redirect script which extracted the textbox contents then redirected the user to the link requested. Hopefull this will give you some ideas. [page.html] <script LANGUAGE="JavaScript"> <!-- function modifyurl (theurl,textvar,thepagename) {
          // do validation here on textvar, textvalue, etc. then proceed with:
          theurl.href="redirect_script.php?requestedpage=" + thepagename + "&textvalue=" + escape(textvar);
} // --> </script> <form name="thetextform" onSubmit="return false;"> <input type="text" name="textvariable" size=30 maxlength=45> </form> <a href="/another_page.html" onClick="modifyurl(this, thetextform.textvariable.value, 'another_page')"> [redirect_script.php] ...and here on the redirect page I would do validation of the variables/form_contents etc., insert it into a db, and then redirect: <? switch ($requestedpage) { case "another_page":
       Header("Location: http://www.site.com/path/to/another_page.html"); //Redirect browser
       break;
case ... } Cheers, Bruce _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

« previous php.general (#81301) next »