< Buzzing or vibrating the login form using jquery Posted On May 15, 2012 : 0 comments << >> Simple div slideshow using jquery Posted On May 9, 2012 : 0 comments << >> Copy mysql column in varchar to type date Posted On May 3, 2012 : 0 comments << >> Enter only numbers inside a input field of a form using javascript Posted On May 1, 2012 : 0 comments << >> Slide in and out animate div vertically using jquery Posted On April 25, 2012 : 1 comment << >> Tag cloud using php, mysql and ajax with filter Posted On April 24, 2012 : 0 comments << >> Change webpage font color or background color from the user side using javascript Posted On April 19, 2012 : 0 comments << >> A single link that cycles through several webpage background color using javascript Posted On April 17, 2012 : 0 comments << >> Simple webpage redirection using perl script Posted On April 10, 2012 : 0 comments << >> Get ipaddress using perl script Posted On April 4, 2012 : 0 comments << >>

Pass PHP Value To Javascript

This Tutorial Has Been Viewed 1,262 Times.
VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)

This is a simple script to pass values from our server side language PHP to the client side script JAVASCRIPT.

Its pretty simple we have two php files.

CONTACT.php and SEND.php

in that you can see like  values which we enter in contact.php will be send to the text fields of send.php

Now to get these values from the send.php you have to use GETELEMENTBYID() functionality of javascript.
Simple is it, grab your code guys
CONTACT.PHP
<table width=”400″ border=”0″ align=”center” cellpadding=”3″ cellspacing=”1″>
<tr>
<td><strong>Contact Form </strong></td>
</tr>
</table>

<table width=”400″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”1″>
<tr>
<td><form name=”form1″ method=”post” action=”send.php”>
<table width=”100%” border=”0″ cellspacing=”1″ cellpadding=”3″>
<tr>
<td width=”16%”>Subject</td>
<td width=”2%”>:</td>
<td width=”82%”><input name=”subject” type=”text” id=”subject” size=”50″></td>
</tr>
<tr>
<td>Detail</td>
<td>:</td>
<td><textarea name=”detail” cols=”50″ rows=”4″ id=”detail”></textarea></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input name=”name” type=”text” id=”name” size=”50″></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name=”customer_mail” type=”text” id=”customer_mail” size=”50″></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type=”submit” name=”Submit” value=”Submit”> <input type=”reset” name=”Submit2″ value=”Reset”></td>
</tr>
</table>
</form>
</td>
</tr>
</table>

SEND.PHP
<?php

// Mail of sender


//code by mistonline.in
$mail_from=$_POST['customer_mail'];

$subject=$_POST['subject'];

$detail=$_POST['detail'];

$name=$_POST['name'];

echo “<input id=’mail’ type=” name=’recipient’ value=’”.$mail_from.”‘>”;

echo “<input id=’detail’ type=” name=’recipient2′ value=’”.$detail.”‘>”;

echo “<input id=’name’ type=” name=’recipient3′ value=’”.$name.”‘>”;

echo “<input id=’sub1′ type=” name=’recipient4′ value=’”.$subject.”‘>”;

?>
<script language=”javascript” type=”text/javascript”>

mail1 = document.getElementById(‘mail’).value

name = document.getElementById(‘name’).value

//subject = document.getElementById(‘sub1′).value

//detail = document.getElementById(‘detail’).value


alert(“The Mail You Entered Is” +mail1)
alert(“The name You Entered Is” +name)
//alert(“The Sub You Entered Is”+ sub1)
//alert(“The detail You Entered Is”+ detail)

//code by Mistonline.in
</script>
Thanks ;)
VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)

Incoming search terms:





You will also be interested in ,

Leave a Reply

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks