WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
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
Submit Site
Forex Trading Online forex trading platform

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 : 5 of 5 (graded 1 times)
Viewed : 9708
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 
 

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>




clearing variables in php3
Categories : Variables, Arrays, PHP
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
Dynamic Calender in PHP, Javascript and HTML.
Categories : PHP, Java Script, HTML and PHP, Calendar
Building dynamic menus with PHP & MySQL (ADO), JavaScript and CSS
Categories : PHP, Databases, MySQL, Java Script, User Interface
PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
Categories : PHP, Arrays, Variables
translate.php - Assocciative array example, passing a reference to a function.
Categories : PHP, Arrays, Languages, Variables
This functions compares the current PHP version with a desired version. Because of the 3 tiered version system, a direct compare of a string to phpversion() will not be accurate.
Categories : PHP Configuration, PHP, Variables
Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view.
Categories : PHP, PHP Classes, Java Script, AJAX, Databases
getting the name of the current script and query string
Categories : PHP, Global Variables, Variables, URLs
Zephyr: AJAX Based Framework for PHP5 Developers
Categories : PHP, AJAX, Frameworks, Java Script, Web Applications
Array values from javascript to php
Categories : PHP, Java Script, Arrays
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET
Categories : Algorithms, HTML and PHP, PHP, Variables
Builds JavaScript that updates the contents of one selector based on another.
Categories : HTML, Java Script, PHP, Complete Programs, General