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

Home » Imported messages » comp.lang.php » How can i get value of text area?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How can i get value of text area? [message #182093] Tue, 09 July 2013 11:55 Go to next message
sanjayrathod273 is currently offline  sanjayrathod273
Messages: 2
Registered: July 2013
Karma: 0
Junior Member
i have two files
1)index.php
and
2)code.js

now code in index.php is below

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<link href="http://web.guru99.com/lib/codemirror.css" rel="stylesheet" />
<script type="text/javascript" src="code.js"></script>
<style type="text/css">
.CodeMirror {
border: 1px solid #eee;
height: auto;
}
.CodeMirror-scroll {
height: auto;
overflow-y: hidden;
overflow-x: auto;
}
</style>
</head>
<body>
Integer : whole numbers e.g. -3, 0, 69. The maximum value of an integer is platform-dependent. On a 32 bit machine, its usually around 2 billion. 64 bit machines usually have larger values. The constant PHP_INT_MAX is used to determine the maximum value.
<pre class="codeguru">say 'hi';</pre>
Let us now look at how PHP determines the data type depending on the attributes of the supplied data.
<pre class="codeguru">say 'hello';</pre>
Floating point numbers
<pre class="codeguru">say 'you r amazing';</pre>
Character strings
<pre class="codeguru">say 'i am fine';</pre>
</div>
<form class="hidden code-box" method="GET" name="sample">
<div dir="ltr"><textarea class="php" name="codeguru"></textarea></div>
<input type="submit" value="Run" onclick="execute();"/>
</br></br>
Output:</br></br>
<textarea id="print-result" disabled="true" cols="77"></textarea></br>
</form></div>
</body>
</html>

and code.js file contain code is given below

$(document).ready(function()
{
$('pre.codeguru').each(function()
{
var pre = this;
var form = $('form[name=sample]').clone();
$(form).removeAttr('name');
$(form).removeClass('hidden');
$($(form).find('textarea')[0]).val($(pre).text());
var id = $(pre).attr('id');
$(form).find('div textarea[name=code]').first().attr('id', id);
$(pre).replaceWith(form);
});
window.editors = [];
$('textarea[name=codeguru]').each(function()
{
window.editor = CodeMirror.fromTextArea(this,
{
lineNumbers: true,
matchBrackets: true,
mode: "application/x-httpd-perl",
tabMode: "shift"
});
editors.push(editor);
});

});
function execute() {
p5pkg.CORE.print = function(List__) {
var i;
for (i = 0; i < List__.length; i++) {
document.getElementById('print-result').value += p5str(List__[i])
}
return true;
};
p5pkg["main"]["v_^O"] = "browser";
p5pkg["main"]["Hash_INC"]["Perlito5/strict.pm"] = "Perlito5/strict.pm";
p5pkg["main"]["Hash_INC"]["Perlito5/warnings.pm"] = "Perlito5/warnings.pm";
var source = editor.getValue();
alert(source);
var pos = 0;
var ast;
var match;
document.getElementById('print-result').value = "";
try {
var start = new Date().getTime();
var js_source = p5pkg["Perlito5"].compile_p5_to_js([source]);
var end = new Date().getTime();
var time = end - start;
// run
start = new Date().getTime();
eval(js_source);
end = new Date().getTime();
time = end - start;
}
catch(err) {
//document.getElementById('log-result').value += "Error:\n";
}
}


everything is run fine in my code. in code.js pre tags are replaced by textarea and the code in textarea should be run because this project is of online perl editor. so now my problem is i have alert the value of text area by this code

var source = editor.getValue();
alert(source);

but that gives the blank pop up. so what i have to do for retrieve current value of textarea?
Re: How can i get value of text area? [message #182094 is a reply to message #182093] Tue, 09 July 2013 12:07 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 7/9/2013 7:55 AM, sanjayrathod273(at)gmail(dot)com wrote:
> i have two files
> 1)index.php
> and
> 2)code.js
>
<snip lots of unrelated code>
>
>
> everything is run fine in my code. in code.js pre tags are replaced by textarea and the code in textarea should be run because this project is of online perl editor. so now my problem is i have alert the value of text area by this code
>
> var source = editor.getValue();
> alert(source);
>
> but that gives the blank pop up. so what i have to do for retrieve current value of textarea?
>

And your PHP question is?

There is no PHP in what you posted - only HTML and javascript.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How can i get value of text area? [message #182097 is a reply to message #182093] Tue, 09 July 2013 14:12 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
Try posting at comp.lang.javascript
Re: How can i get value of text area? [message #182102 is a reply to message #182093] Tue, 09 July 2013 15:44 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Tue, 09 Jul 2013 04:55:55 -0700, sanjayrathod273 wrote:

> i have two files 1)index.php and 2)code.js

............

> but that gives the blank pop up. so what i have to do for retrieve
> current value of textarea?

You need to perform the ritual on page 87 of "The Darkest Arts of
Midnight - Pizza, Cola and ASM86 at 3AM"[1] using 2 goats, 5 chickens and
a still shrink-wrapped copy of ms-dos 3.3, or alternatively 3.1415926 cc
of cobra venom.

[1] If you're worthy of handling the sacred knowledge within the hallowed
pages you already have a copy, which is why I don't need to tell anyone
here where to obtain it.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: How can i get value of text area? [message #182103 is a reply to message #182093] Wed, 10 July 2013 00:02 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
sanjayrathod273(at)gmail(dot)com wrote:
> so what i have to do for retrieve current value of textarea?

It is probably best to ask in a CodeMirror related support forum/newsgroup.

However, a hint from glancing over the lengthy code: you're assigning
new CodeMirror instances to window.editor in a loop, so window.editor
contains the last instance that was created. You may consider
inspecting window.editors in the dev tools of your browser.[1]

And you may consider to get a real name, and to trim your code samples
to the required minimum to be able to reproduce the problem.[2] And you
may consider avoiding global variables as far as possible.[3]

[1] <http://devtoolsecrets.com/>
[2] <http://www.catb.org/esr/faqs/smart-questions.html>
[3] <http://c2.com/cgi/wiki?GlobalVariablesAreBad>

--
Christoph M. Becker
Re: How can i get value of text area? [message #182110 is a reply to message #182093] Wed, 10 July 2013 20:25 Go to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
sanjayrathod273(at)gmail(dot)com wrote:

> i have two files
> 1)index.php
> and
> 2)code.js

No, you have copied them from <http://web.guru99.com/data-types-variables-and-operators/> without telling us (or them).

You cannot simply copy the client-side code from a PHP-powered Web site
(they are using WordPress, but the editor makes it clear already) and expect
it to work the same at your box. Also, you MUST NOT do that (except perhaps
for non-public use; check your local Copyright laws – IANAL).

But any Web site that makes claims like

| PHP is a loosely typed language; it does not have explicit defined data
| types.
|
| PHP determines the data types by analyzing the attributes of data
| supplied.
|
| PHP implicitly supports the following data types […]

is not to be trusted anyway.

PHP is _not_ a “loosely typed” language (that term is “loosely *defined*”
itself; avoid it). It is a language with dynamic type-checking (at runtime,
as opposed to static type-checking at compile-time).

That means it *has* “explicit defined data types”, but that symbols
(variables, array member, classes, properties) do not have a type as in “is
declared as” or “enforce” (at *compile time*), and that *values* have a type
instead. The type of the symbol is defined by the value it stores or refers
to, at *runtime*. In some cases, as with type hinting and setters/getters,
more strict type-checking or implicit type conversion, can be enforced on
function parameters and properties. As such, PHP without type hinting can
be called a “weakly typed” language according to Liskov and Zilles, and
Jackson (referred in [1]).

Data types are supported in PHP *explicitly*. Each PHP value has a type in
the Zend2 PHP engine:

<http://www.php.net/manual/en/internals2.variables.intro.php> etc.

So the gettype() function does _not_ “[analyze] the attributes of data
supplied”, it just reads the “type” member of the zval and maps it to a
human-readable string value.

As with other languages with dynamic type-checking (such as ECMAScript
implementations like JavaScript, for a prominent example), implicit type
*conversion* (in PHP also called “type juggling”) is performed with certain
operators:

<http://www.php.net/manual/en/language.types.php>

You are better off reading <http://php.net/manual>, asking specific
questions in this newsgroup, or taking a PHP class at Zend.com than reading
this tutorial. And you will learn more about PHP by setting it up on your
computer than by using a Web editor.


PointedEars
___________
[1] <http://en.wikipedia.org/wiki/Strong_and_weak_typing>
--
When all you know is jQuery, every problem looks $(olvable).
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Help with Security Have I coded this correctly?
Next Topic: PHPMailer from and mesg-id bug
Goto Forum:
  

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

Current Time: Thu Nov 28 06:50:20 GMT 2024

Total time taken to generate the page: 0.02715 seconds