FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how to pass text set in a javascript?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: how to pass text set in a javascript? [message #178859 is a reply to message #178857] Wed, 15 August 2012 06:08 Go to previous messageGo to previous message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma:
Senior Member
On 8/15/2012 5:51 AM, thejustpark wrote:
> In my php page, I have this text area whose text data I want to pass to the php code set in action field.
> Of course, this is working.
> But then, I placed a little button below the text area, so that if a user clicks on it, an example text message gets on there.
> Of course, it is expected that if I click on submit button, this should be able to be passed as data.
> But I find it not working.
>
> OK, let me summarize with a code snippet.
>
> I have the following form.
> <form name="input" action="next.php" method="post" enctype="multipart/form-data" class="SearchForm" target="_self">
> <textarea id="fgData" name="fgData" class="xxlarge" rows="10" disabled="">
> <input type="button" value="Example load" onclick="loadExample();">
> </form>
>
> And loadExample is declared on ahead as in the following:
> <script type="text/javascript">
> <!--

The above script-hiding techniques stopped making sense over 10 years ago.
I think you can safely stop using that nowadays.

> function loadExample() {
> document.forms["input"].fgData.value = "asdf";

In my humble opinion, "input" is a confusing name for a form.
Also consider addressing the elements of the form like this:
document.forms["input"].elements["fgData"].value = "asdf";


> }
> //-->
> </script>
>
> It actually puts "asdf" on fgData text area.
> However as I click the submit button and echo $fgData;, it doesn't print anything,
> meaning it is not passed over.
>
> What am I missing to pass the data?

Your example looks fine to me.

But this becomes a PHP question now.
So, from PHP (the target of the form, being next.php) add this at the
beginning of your script to check:
<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
exit;

That way you will see on screen what PHP receives in $_POST.

Regards,
Erwin Moller

>
> Thanking in advance,
> Justpark.
>


--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHPUnit documentation
Next Topic: Create hierarchical tree structure for categories in joomla
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 15:31:47 GMT 2024

Total time taken to generate the page: 0.04539 seconds