View Full Version : Function Text Box
07-12-2012, 01:17 AM
Would there be a way to have a text box that would do a function so if you typed in print("") it would give the pages value whaterver is in ""? Or something similar so I could build in some function that would use a part of it as a variable?
07-12-2012, 01:27 AM
Do WHAT "function"? You mean, in your example, print something?
And what does "pages value" mean?
In general, the answer is "yes", but it really wouldn't be a good idea to just execute whatever is typed in. A user could type in something that would utterly mess up his display and then he would blame you.
07-12-2012, 01:33 AM
Well this would just be for me what I mean is pagvalue would be a div and you could type in Print("") or some other commands and whatever is in"" the value of the page would be that.
I am trying to make some basic commands for something. Is there a way to parse it so if the first parts Print then get whatev is in "" and set pagevalue.value = ""?
07-12-2012, 01:37 AM
Yes, but then why bother with print("")???
<input type="text" onchange="document.getElementById('pagevalue').innerHTML=this.value"/>
07-12-2012, 01:38 AM
Maybe you need to give a real example?
07-12-2012, 04:30 AM
Ok. Ill have 2-3 commands and one of them will print the other ones will do something else. So that why it needs to be a unique name. I know how to assighn text but I want to have a command. Its not going to be a command line but on a command line you type a keyword of function in and it executes.
07-12-2012, 07:31 PM
I kinda figured it out here.
07-12-2012, 07:38 PM
Ok this gets it correct but it leaves the closing ) in there any ideas?
var b = str.indexOf("(");
var d = str.indexOf(")");
07-13-2012, 04:32 PM
How could I check if thers 2 characters and get the value. Becasue for one there coule be 1-2 characters? Would I check if the next character is a number or something
07-13-2012, 08:57 PM
I just think you are working way way too hard.
But if you insist on doing it as you are:
if ( str.toLowerCase().indexOf("print(") == 0 )
var q = str.substring( 6 );
q = q.substring( 0, q.length-1 );
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.