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


Groups > comp.lang.php > #10045 > unrolled thread

How can i get value of text area?

Started bysanjayrathod273@gmail.com
First post2013-07-09 04:55 -0700
Last post2013-07-10 22:25 +0200
Articles 6 — 6 participants

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


Contents

  How can i get value of text area? sanjayrathod273@gmail.com - 2013-07-09 04:55 -0700
    Re: How can i get value of text area? Jerry Stuckle <jstucklex@attglobal.net> - 2013-07-09 08:07 -0400
    Re: How can i get value of text area? bill <william@TechServSys.com> - 2013-07-09 10:12 -0400
    Re: How can i get value of text area? Denis McMahon <denismfmcmahon@gmail.com> - 2013-07-09 15:44 +0000
    Re: How can i get value of text area? Christoph Michael Becker <cmbecker69@arcor.de> - 2013-07-10 02:02 +0200
    Re: How can i get value of text area? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-10 22:25 +0200

#10045 — How can i get value of text area?

Fromsanjayrathod273@gmail.com
Date2013-07-09 04:55 -0700
SubjectHow can i get value of text area?
Message-ID<d4d1b24a-9d60-4d25-8949-5fbf65d1fb27@googlegroups.com>
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?

[toc] | [next] | [standalone]


#10046

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-07-09 08:07 -0400
Message-ID<krgu2d$kls$1@dont-email.me>
In reply to#10045
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
==================

[toc] | [prev] | [next] | [standalone]


#10049

Frombill <william@TechServSys.com>
Date2013-07-09 10:12 -0400
Message-ID<krh5nr$s6a$2@speranza.aioe.org>
In reply to#10045
Try posting at comp.lang.javascript

[toc] | [prev] | [next] | [standalone]


#10054

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-07-09 15:44 +0000
Message-ID<krhb54$4if$3@dont-email.me>
In reply to#10045
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

[toc] | [prev] | [next] | [standalone]


#10055

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2013-07-10 02:02 +0200
Message-ID<51dca47f$0$6573$9b4e6d93@newsspool3.arcor-online.net>
In reply to#10045
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

[toc] | [prev] | [next] | [standalone]


#10062

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-07-10 22:25 +0200
Message-ID<5479816.A5F48n2xs2@PointedEars.de>
In reply to#10045
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).

[toc] | [prev] | [standalone]


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


csiph-web