Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15370 > unrolled thread

how to pass text set in a javascript?

Started bythejustpark <thejustpark@gmail.com>
First post2012-08-15 18:34 -0700
Last post2012-08-15 21:24 -0700
Articles 2 — 1 participant

Back to article view | Back to comp.lang.javascript


Contents

  how to pass text set in a javascript? thejustpark <thejustpark@gmail.com> - 2012-08-15 18:34 -0700
    Re: how to pass text set in a javascript? thejustpark <thejustpark@gmail.com> - 2012-08-15 21:24 -0700

#15370 — how to pass text set in a javascript?

Fromthejustpark <thejustpark@gmail.com>
Date2012-08-15 18:34 -0700
Subjecthow to pass text set in a javascript?
Message-ID<855e4568-1663-4362-8e47-e97873cdd33f@googlegroups.com>
In my php page, I have this text area whose text data I want to pass to the php code set in the action field. 
This is working, when I type something in the area. 
But then, I placed a little button below the text area, so that if a user clicks on it, an example text gets on there. 
Then, I expect that if I click on the submit button, the example text is passed to next.php . 
But I find it not working. 

OK, let me summarize with a code snippet. 

<script type="text/javascript"> 
<!-- 
function loadExample() { 
document.forms["region"].elements['fgData'].value = "asdf"; 
alert("asdf"); 
} 
//--> 
</script> 

<form name="region" action="calculator_sub.php" method="post" enctype="multipart/form-data" target="_self"> 
<textarea id="fgData" name="fgData" class="xxlarge" rows="10" disabled="disabled"> </textarea> 
<input type="button" value="Example load" onclick="loadExample();"> 
<input type="submit" class="btn primary" id="submit_button" value="Submit"> 
</form> 

The button actually puts "asdf" on fgData text area. 
But when I do 
<?php 
echo "<pre>"; 
print_r($_POST); 
echo "</pre>"; 
?> 

in next.php, there isn't even a variable named fgData. 
What am I missing to pass the data? 

Thanking in advance, 
Justpark. 

[toc] | [next] | [standalone]


#15372

Fromthejustpark <thejustpark@gmail.com>
Date2012-08-15 21:24 -0700
Message-ID<34bfd5c9-8771-4fac-89a8-08e253e9b9a0@googlegroups.com>
In reply to#15370
On Wednesday, August 15, 2012 8:34:57 PM UTC-5, thejustpark wrote:
> In my php page, I have this text area whose text data I want to pass to the php code set in the action field. 
> 
> This is working, when I type something in the area. 
> 
> But then, I placed a little button below the text area, so that if a user clicks on it, an example text gets on there. 
> 
> Then, I expect that if I click on the submit button, the example text is passed to next.php . 
> 
> But I find it not working. 
> 
> 
> 
> OK, let me summarize with a code snippet. 
> 
> 
> 
> <script type="text/javascript"> 
> 
> <!-- 
> 
> function loadExample() { 
> 
> document.forms["region"].elements['fgData'].value = "asdf"; 
> 
> alert("asdf"); 
> 
> } 
> 
> //--> 
> 
> </script> 
> 
> 
> 
> <form name="region" action="calculator_sub.php" method="post" enctype="multipart/form-data" target="_self"> 
> 
> <textarea id="fgData" name="fgData" class="xxlarge" rows="10" disabled="disabled"> </textarea> 
> 
> <input type="button" value="Example load" onclick="loadExample();"> 
> 
> <input type="submit" class="btn primary" id="submit_button" value="Submit"> 
> 
> </form> 
> 
> 
> 
> The button actually puts "asdf" on fgData text area. 
> 
> But when I do 
> 
> <?php 
> 
> echo "<pre>"; 
> 
> print_r($_POST); 
> 
> echo "</pre>"; 
> 
> ?> 
> 
> 
> 
> in next.php, there isn't even a variable named fgData. 
> 
> What am I missing to pass the data? 
> 
> 
> 
> Thanking in advance, 
> 
> Justpark.

Oh it was because the textarea was disabled. 
I added 
document.forms["region"].elements['fgData'].disabled=false;, and now it's working!!

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web