[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

button type updates textarea?

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
pillmill
Asked:
pillmill
1 Solution
 
micropc1Commented:
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
 
ProculopsisCommented:
<!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
 
Ray PaseurCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
pillmillAuthor Commented:
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
 
micropc1Commented:
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
 
Ray PaseurCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now