Solved

button type updates textarea?

Posted on 2012-03-12
6
310 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
6 Comments
 
LVL 7

Accepted Solution

by:
micropc1 earned 500 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 108

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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 108

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now