Page 1 of 1

pass a value from a javascript to a php file

Posted: Thu Aug 06, 2009 4:35 am
by revbackup
I have a problem doing mysql queries with javascript....
I don't know how to get the value returned by the javascript and pass it as
a parameter in a php function so that in the php function, i can do my
UPDATE query there.



So, this is my code: The one in blue is my problem... content.current is the value in which I need
to update to my database.... How can I pass that value to a php function as a parameter????

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FANCY EDIT-ON-PLACE</title>
<style>
.input {
    color: #f00;
    background: #00CCCC;
    width: 400px;
}
div button{
    color: #f0f;
}
.style1 {color: black}
.style2 {color: #FFFF00}
</style>
 
<script type="text/javascript" src="ajax.js"></script>
<script language="javascript" type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script language="javascript" type="text/javascript" src="editable-1.1.0-extended.js"></script>
<script>
 
 
 
$(function(){
    //#
    function begin(){
        this.append('Double Click to submit');
    }
    function end(content){
[color=#0040FF] //what i need is to pass content.current into a php file so that i can do my UPDATE query there using the value of content.current
    alert(content.current)[/color]
        
    
    }
    $('div.editable').editable({
                        onSubmit:end
                        });
    //checkbox editable
                            
});
</script>
</head>
<body>
 
    <div class="editable style1"  id=thediv onmouseover="mouseover()" onmouseout="mouseout()" >click me to edit</div>
    <div id="employ_data"></div>
</body>
</html>
 
<?php
if (is_numeric($_GET['employ_id'])) {
echo "Ryan Valmoria, You are on the way....!!!!!!!!!";
}
?> 
 

Re: pass a value from a javascript to a php file

Posted: Thu Aug 06, 2009 8:52 am
by jackpf
You'll need to either submit the page to a php script to process, or use AJAX to send the data.