Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Php +javascript

Status
Not open for further replies.

MUDASAR

IS-IT--Management
Dec 25, 2004
1
GB
hi,
I want to show the entered data in the textfield. by clicking on the button,but unable to do that.plz solve my this problem .I'm pasting the code below plz correct the code & tell me my mistake.
thanx


<html>
<head>
<title>Title here!</title>

</head>
<body>


<input type=&quot;button&quot; ONCLICK=&quot;mush()&quot; value=&quot;click me&quot;>
<input type=&quot;textarea&quot; name=&quot;area&quot; >
</textarea>

<?
echo &quot;
<script language='javascript' >
function mush() { \n&quot;;

echo &quot; alert( \&quot;$area\&quot; );
}

</script>&quot;;
?>

</BODY>
</html>
 
1. you don't enclose your form tags in a form !!! (this is a HTML problem, your page can't be properly parsed if you forget this !)
<form .....>
<input type=....>
...
</form>
(also you CAN't open an INPUT tag and close a TEXTAREA tag like in the 3rd and 4th lines - this is a HTML problem as well)
2. you don't submit your form !!! (PHP is SERVER side so you HAVA TO send the form to the server for php to know it has something to do)
* either
<form .....>
<input type= ....>
...
<input type=submit value=&quot;click me&quot;>
</form>
* or :
<form .....>
<input type=.... onclick=&quot;javascript:this.form.submit()&quot;>
...
</form>
2 bis - alternativly, you can do the same thing WITHOUT USING PHP, jsut with plain javascript, without having to call the server, but as it's the PHP forum here i guess you want to use php

3. you don't tell the form which page it should call (ie, where the server should look for processing what was entered) Obviously you'd like it to be the same page so it's
<form ... action=<?php echo($PHP_SELF); ?>>

4. you're using php functions in javascript (&quot;echo &quot; is definitly NOT javascript !!!) so the browser can't understand what you want to do
use plain php as you seem to have troubles with html/javascript
and it's even easier :
<?php echo($area); ?>

--------- so now your code is
<form ... action=<?php echo($PHP_SELF); ?>>
<textarea name=area ...>
</textarea>
<input type=submit value=&quot;click me&quot;>
</form>
<?php echo($area); ?>
--------

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top