WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : How to display a PHP variable value from a selectbox without reloading the page by merging PHP and Javascript variables.
Categories : PHP, Java Script, Variables Update Picture
Andy Krause
Date : Nov 24th 2000
Grade : 3 of 5 (graded 4 times)
Viewed : 31547
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Andy Krause
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

The following example somehow gives the opportunity to combine Javascript and PHP
variables, which usually would only be possible in one way, giving a Javascript the variables
from PHP, but not reverse.

The trick is, to make the selectbox send a value with two variables:
1. the variable from PHP,
2. the value of this variable

As this will be an array for javascript, it need to be split into single parts again and
the value can be used in another formfield.

With enough fantasy, this code can solve a lot of ideas, I guess.
Let me know...

n-dee

ark@anyweb.at

--------------------
Put this code in a PHP file:

<html>

<script language="JavaScript">
        <!--
        function GetVarValue(field)        {
                selected=false;
                for (Count = 0; Count < document.forms[0].strCfgVar.length; Count++){
                        if(document.forms[0].strCfgVar[Count].selected){
                        selected=true;                                
                        var string = document.forms[0].strCfgVar[Count].value;
                        var stringArray = string.split(",");
                        strCfgVarValue = stringArray[1];
                        }
                }
                if ((navigator.appName.indexOf("Microsoft") != -1) && (parseInt
(navigator.appVersion) >= 4)){
                        document.forms[0].currVal.style.backgroundColor="yellow";
                        }
                document.forms[0].currVal.value=strCfgVarValue;
                document.forms[0].currVal.focus();
                return true;
        }
        //-->
</script>

<?
// these data should come from a config-file e.g.
// with include("FILE");
$cfgDbHost="localhost";
$cfgDbUser="AdminUser";
?>

<table align="center" border="0"><tr>
<form method="POST" name="selectform" action="<? echo $PHP_SELF ?>">
<tr><td>Variable: </td><td>
        <select name="strCfgVar" onChange="GetVarValue(this)">
        <option value=""></option>
        <option value="cfgDbHost,<? echo $cfgDbHost ?>">DB-Host</option>
        <option value="cfgDbUuser,<? echo $cfgDbUser ?>">DB-User</option>        
        </select>
        </td>
        <td>Current Value: <input type="text" name="currVal" size="30"></td><td>
        </tr></table>

</html>




day and week grid with clickable fields on/off and possibility to insert in DB
Categories : PHP, Java Script, CSS
This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field
Categories : PHP, MySQL, Java Script, HTML and PHP
PHP Interaction with Javascript windows
Categories : Java Script, PHP
Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
Categories : PHP, Directories, Variables, Arrays
Functions to read a template file and fill in PHP variables. It will also fill in array variables, displaying parts of the template multiple times.
Categories : PHP, Variables, Filesystem
How to make sure a that $foo is from a cookie and not from the URI.
Categories : PHP, Variables, Global Variables, Cookies
Working with files - return an array of files within a directory
Categories : PHP, Strings, Variables, Filesystem
Accessing GET and PUT variables with HTTP_GET_VARS on Win2K.
Categories : PHP, Windows 2000, Variables
Building dynamic menus with PHP & MySQL (ADO), JavaScript and CSS
Categories : PHP, Databases, MySQL, Java Script, User Interface
Date Validation using JavaScript. Intended to use it as checkdate() from PHP.
Categories : Java Script, Date Time, PHP
A database abstraction layer for the PHP Oracle 8 module (available from PHP 3.0.5). It supports persistent connections, fetching rows into arrays, prepare/execute (variable binding) and has a new and improved error interface.
Categories : Databases, Oracle, PHP, Arrays, Variables
Password using php, Javascript, and html form
Categories : Security, PHP, Authentication, Java Script
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides
enhanced date picker with jcript checking for a dynamic date input
Categories : PHP, Java Script, Date Time, Calendar, Arrays
How to know which input button of type image was pressed in a form with multiple image buttons (_x and _y) in PHP?
Categories : PHP, Variables, HTML