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 #178860 is a reply to message #178857] Wed, 15 August 2012 18:30 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Tue, 14 Aug 2012 20:51:23 -0700, thejustpark wrote:

> OK, let me summarize with a code snippet.

The button to load your example text does not need to be a part of the
form, but your form submit button does. Your "Input" button is not acting
as a submit button because of the function call. If you want it to act as
a submit, you need to make the function return the logical value true.

Your textarea should be closed with </textarea>

disabled="" is better written as disabled="disabled". If you don't want
the textarea disabled, omit the attribute completely. It is better to get
into good habits now, than into bad ones. People who got into bad habits
when they started writing html are still making mistakes 15+ years later
from those same bad habits. (Hi Alexander Baron)

Try this (moving the load text button outside the form, using a submit in
the form):

<p>
<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=""></textarea><br>
<input type="submit" value="Submit">
</form>
<br>
<input type="button" value="Example load" onclick="loadExample();">
</p>

*OR* try changing the script to this:

<script type="text/javascript">
function loadExample() {
document.forms["input"].fgData.value = "asdf";
return true;
}
</script>

In either case, put the closing </textarea> after the opening one.

One other thing, it seems your question relates to javascript and html,
but you posted it on a php newsgroup. Please use a more appropriate
newsgroup next time, or you may find that your reception becomes less
friendly.

Rgds

Denis McMahon
[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: Mon Nov 25 03:57:25 GMT 2024

Total time taken to generate the page: 0.03794 seconds