f



How can i get value of text area?

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

now code in index.php is below

    <html>
    <head>
    <script src=3D"http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquer=
y.min.js"></script>
    <link href=3D"http://web.guru99.com/lib/codemirror.css" rel=3D"styleshe=
et" />
    <script type=3D"text/javascript" src=3D"code.js"></script>
    <style type=3D"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 use=
d to determine the maximum value.
    <pre class=3D"codeguru">say 'hi';</pre>
    Let us now look at how PHP determines the data type depending on the at=
tributes of the supplied data.
    <pre class=3D"codeguru">say 'hello';</pre>
    Floating point numbers
    <pre class=3D"codeguru">say 'you r amazing';</pre>
    Character strings
    <pre class=3D"codeguru">say 'i am fine';</pre>
    </div>
    <form class=3D"hidden code-box" method=3D"GET" name=3D"sample">
    <div dir=3D"ltr"><textarea class=3D"php" name=3D"codeguru"></textarea><=
/div>
    <input type=3D"submit" value=3D"Run" onclick=3D"execute();"/>
    </br></br>
    Output:</br></br>
        <textarea id=3D"print-result" disabled=3D"true" cols=3D"77"></texta=
rea></br>
    </form></div>
    </body>
    </html>

and code.js file contain code is given below

    $(document).ready(function()=20
    {
    	$('pre.codeguru').each(function()=20
    	{
            	var pre =3D this;
    	        var form =3D $('form[name=3Dsample]').clone();
            	$(form).removeAttr('name');
    	        $(form).removeClass('hidden');
            	$($(form).find('textarea')[0]).val($(pre).text());
    	        var id =3D $(pre).attr('id');
            	$(form).find('div textarea[name=3Dcode]').first().attr('id', i=
d);
    		$(pre).replaceWith(form);
            });
            window.editors =3D [];
            $('textarea[name=3Dcodeguru]').each(function()=20
            {
            	window.editor =3D CodeMirror.fromTextArea(this,=20
            	{
    	        	lineNumbers: true,
    	        	matchBrackets: true,
    	        	mode: "application/x-httpd-perl",
            		tabMode: "shift"
               	 });
                	editors.push(editor);
            });
    	=09
    });
    function execute() {
                p5pkg.CORE.print =3D function(List__) {
                    var i;
                    for (i =3D 0; i < List__.length; i++) {
    		    	  document.getElementById('print-result').value +=3D p5str(List_=
_[i])
                    }
                    return true;
                };
                p5pkg["main"]["v_^O"] =3D "browser";
                p5pkg["main"]["Hash_INC"]["Perlito5/strict.pm"] =3D "Perlit=
o5/strict.pm";
                p5pkg["main"]["Hash_INC"]["Perlito5/warnings.pm"] =3D "Perl=
ito5/warnings.pm";
    			var source =3D editor.getValue();
    			alert(source);
                var pos =3D 0;
                var ast;
                var match;
    		    document.getElementById('print-result').value =3D "";
                try {
                    var start =3D new Date().getTime();
                    var js_source =3D p5pkg["Perlito5"].compile_p5_to_js([s=
ource]);
                    var end =3D new Date().getTime();
                    var time =3D end - start;
                    // run
                    start =3D new Date().getTime();
    		    	eval(js_source);
                    end =3D new Date().getTime();
                    time =3D end - start;
                }
                catch(err) {
                    //document.getElementById('log-result').value +=3D "Err=
or:\n";
                      }
    		}

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

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

but that gives the blank pop up. so what i have to do for retrieve current =
value of textarea?
0
7/9/2013 11:55:55 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

5 Replies
676 Views

Similar Articles

[PageSpeed] 10

On 7/9/2013 7:55 AM, sanjayrathod273@gmail.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@attglobal.net
==================
0
jstucklex (14659)
7/9/2013 12:07:04 PM
Try posting at comp.lang.javascript
0
william429 (96)
7/9/2013 2:12:12 PM
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@gmail.com
0
7/9/2013 3:44:36 PM
sanjayrathod273@gmail.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
0
cmbecker691 (145)
7/10/2013 12:02:12 AM
sanjayrathod273@gmail.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).
0
PointedEars (2489)
7/10/2013 8:25:42 PM
Reply: