?
Solved

button type updates textarea?

Posted on 2012-03-12
6
Medium Priority
?
356 Views
Last Modified: 2012-03-19
I need to use a button to update a textarea.

I can update textboxes using javascript called on a button click:

html: <input type='button' id='submit' value='submit' onclick='ex()'>

javascript: document.getElementById("field").value="<?php  echo $_SESSION['value']; ?>";

However, the textarea can only be updated by using a submit and embedded php:

 <textarea name="test1" rows="20" cols="80" >
     <?php if (isset($_FILES['files']))    
     $rawoutput=passthru($program);} ?>
</textarea>

How can I have the textarea updated by the button click event?
0
Comment
Question by:pillmill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Accepted Solution

by:
micropc1 earned 2000 total points
ID: 37713064
You need to assign an id to the textarea...

 <textarea name="test1" id="test1" rows="20" cols="80" >
     <?php if (isset($_FILES['files']))    
     $rawoutput=passthru($program);} ?>
</textarea>

then you can do it the same way..

javascript: document.getElementById("test1").value="<?php  echo $_SESSION['value']; ?>";
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37713938
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> - jsFiddle demo</title>
 
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
 
<script type='text/javascript'>//<![CDATA[
$(function(){
$("#stash").hide();

$("#submit").click(function() {

    $("textarea[name=test1]").val($("#stash").val());

});
});//]]>  

</script>

</head>
<body>
  <input type='button' id='submit' value='submit' />

<textarea name="test1" rows="20" cols="80" >
</textarea>

<textarea id="stash">
     <?php if (isset($_FILES['files']))    
     $rawoutput=passthru($program);} ?>
</textarea>

</body>
</html>
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37714112
www.laprbass.com/RAY_temp_pillmill.php
<?php // RAY_temp_pillmill.php
error_reporting(E_ALL);
var_dump($_GET);
?>
<form name="foo">
<textarea name="wilma" id="bar"></textarea>
<input type="button" id="loader" value="load" onClick="javascript:document.getElementById('bar').value='Loaded'; return TRUE;" />
<input type="button" id="dumper" value="dump" onClick="javascript:document.getElementById('bar').value='Dumped'; return TRUE;" />
<input type="submit" value="Send Textarea" />
</form>

Open in new window

0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:pillmill
ID: 37727025
Thanks for the suggestions, but none work.

Ray, I modified your program. Why doesn't the php to return
the $_GET values - "dumpget" - work ?

<?php // RAY_temp_pillmill.php
error_reporting(E_ALL);
var_dump($_GET);
?>
<form name="foo">
<textarea name="wilma" id="bar"></textarea>
<input type="button" id="loader" value="load" onClick="javascript:document.getElementById('bar').value='Loaded'; return TRUE;" />
<input type="button" id="dumper" value="dump" onClick="javascript:document.getElementById('bar').value='Dumped'; return TRUE;" />
<input type="button" id="dumper" value="dumpget" onClick="javascript:document.getElementById('bar').value='<?php var_dump($_GET);?>'; return TRUE;" />
<input type="submit" value="Send Textarea" />
</form>[/code]

Open in new window

0
 
LVL 7

Expert Comment

by:micropc1
ID: 37727109
You may want to try doing a search and replace on var_dump to remove any special java characters....single and double quotes especially.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37727320
I looks OK to me, in that it does exactly what the HTTP specifications call for.  It may be somewhat confused by the use of unescaped quotes and apostrophes, but that is the sort of output you have to expect from PHP diagnostic functions like var_dump().  They are not designed to produce a JSON string or HTML-safe form controls.  

This may not be exactly what you want, but I do not see anything that is wrong.  You may want to change the duplicate id attribute.  You can only have one of those on each document.

What are you trying to achieve?  If you can describe it in non-technical terms we may be able to help.
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question