Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 24th, 2005, 01:00 PM
Registered User
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to onmcv
Default passing php variable to javascript and vice versa

i wrote this html form to gather some info...
<title> The form </title>
<form name="myform" action = "gettodb.php" method = "post" >
Enter Id:<br>
<input type="text" name="id" ><br>
Enter date:<br>
<input type="text" name="date1" ><br>
<select name="col">
<option value ="blue">blue
<option value ="black">black
<option value ="yellow">yellow
<input type = "submit" value="Enter"><br>

in gettodb.php i need to perform some operations on the date1 variable using javascript then pass the processed variable back to php to store it in mysql car table.. here the gettodb.php code..


extract( $_POST );
if (!$id || !$date1 || !$col)
echo "not entered";

echo "
<script language = \"JavaScript\">
document.write("in in in");
var date1='$date1'
function convert(date1)
var arg = date1.split("-");
var l,n,i,j,k;
    var d=parseInt(arg[2]);
    var m=parseInt(arg[1]);
    var y=parseInt(arg[0]);
    var jd=intPart((11*y+3)/30)+354*y+30*m-intPart((m-1)/2)+d+1948440-385;
    var aa = jd;

                    if (jd> 2299160 )



function intPart(floatNum){
if (floatNum< -0.0000001){
return Math.ceil(floatNum-0.0000001)
return Math.floor(floatNum+0.0000001)

@ $db=mysql_pconnect("localhost","","");
{echo "error";

$q="insert into car values ('".$id."','".$col."','".$date1."')";
if ($r)
echo mysql_affected_rows()."car inserted";


best regards..

Similar Threads
Thread Thread Starter Forum Replies Last Post
String to attribute and vice versa Pankaj C XSLT 5 February 13th, 2008 06:42 AM
Query to change rows into columns and vice versa miamikk SQL Language 0 November 13th, 2007 06:41 PM
Numbers to words and vice versa? code_lover SQL Language 0 January 7th, 2007 04:50 PM
Word to XML and vice versa using C# asp.net veeruu ASP.NET 1.0 and 1.1 Professional 2 July 21st, 2006 07:41 PM
Passing javascript variable to html or php ashraf_gawdat Javascript How-To 3 July 12th, 2006 02:48 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.