Using Tokenizer To Read Everything Before Carriage Return
Mar 16, 2010
I think I have the regex side of this script worked out. But I need to get everything into an array for regex to read. Is there a way to use tokenizer to read everything before a carriage return? Each line should be added to an array for the regex to analyze and parse as needed. It's been ages since I touched tokenizer, so I forgot most of it. This is the text area in the html that the script should reference.
<textarea cols="60" rows="14" value="" id="paste" name="paste">
This JS limits the input characters into the form. How do I modify it so that it also allows CARRIAGE RETURN and BACKSPACE (for making text correction)?
Due to the template engine I am using, I cannot use IF/ELSE statement.
<form>
<textarea name="event_description" ONKEYPRESS="if (document.layers) var c = event.which; else if (document.all) var c = event.keyCode; else var c = event.charCode; var s = String.fromCharCode(c); return /[0-9a-zA-Zs,.?!@#$%&*()-]/.test(s);"></ textarea> </form>
The function below is triggered via the "onkeyup" event of a text box. I need to test to see if the [enter] key has been pressed, and if so, call a function. With the code below, the pressing of the enter key is traped, but the ascii value for the last "printable" characteris displayed and not chr(13).
I am trying to do a small website for our family to keep track of each other's home address and etc. Using asp for the codes .. (Its been ages since I indulge myself). I have 2 forms.
In which in FormA, I will key in the following address 666, ST Avenue #03-09 Anchor View Residence 123456
When I click on submit it shows this on FormB 666, ST Avenue #03-09 Anchor View Residence 123456
How do I get it to be shown as 666, ST Avenue #03-09 Anchor View Residence 123456 in FormB
In my formB.asp, for the particular code, all I wrote was {Form.address}.
I'm trying to load an ASP recordset into a javascript array via an ASP array. The way I've been attempting to do it is by having ASP "Response.Write()" the javascript code that builds the javascript array. It ALMOST works :rolleyes:
The problem I'm having is that the ASP writes the different javascript lines as one long line (ie. no carriage returns). Therefore, the javascript lines are not recognized. When I take the source code and manually separate the lines produced...then when I run the modified source, it works fine. Code:
I have a calendar where i write my events. If I have 2 events in the same day, how to put a carriage return between the events in the alert part of message? For example, I want this alert message:
Event one to the office. Event two to the store.
The string that I use actually is:
fAddEvent(2003,9,17," Event one. Event two.","alert('Event one to the office. Event two to the store.');","#00ff00","red");
I am building a string inside a variable prior to printing it on screen as follows : myclock += hours+':'+minutes; where "hours" and "minutes" are variables initialised elsewhere. How can I add a carriage return or new line character to the end of this line, so that anything else cocatenated to this variable is displayed on the next line.
I'm creating a new email in javascript via outlook. When i try entering a line break " etc, Outlook just ignores it completely. I've tried using "%0D%0A" and "fromCharCode(10)" as well but it doesnt seem to read it as a line break. Is there any way to code it so that a line break or a carriage return appears on outlook?
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the comment through a pop-up that contains a textarea. When the user hits OK on the pop-up, the text in the textarea is sent to a function on the main page. The function inserts the text into the div's text node.
Please don't ask why I'm making this so complicated - there are other things going on on the page and the pop-up that are irrelevant to my problem.
Everything works perfectly except when the user puts carriage returns in their comment. For some reason I can't get the carriage returns to show up in the div. BUT! When they view the existing comment in the div (the one pulled from the database) the carriage returns are displayed. That initial display does not use any javascript - it's just php so the page is initially rendered with the text in the div.
So it seems that when I programmatically put text into my div, the carriage returns don't show. But if the page is rendered with the text already there, the carriage returns do show.
This seems like it should be so simple, what am I doing wrong??? Do I have to replace the carriage returns with a different character (e.g. <br>, , ,
In a textarea, is there a javascript (or something in php) that will convert carriage returns to spaces when submitted? The textarea on these forums does what I'm trying to accomplish but I've looked at the code and I cannot figure out how it's done.
with jquery, i try to get the margin-left ($('#mydiv').css('margin-left'), but the function return 0px, unable to retrieve the good value (auto) anyone has idea to retrieve the value "auto" when margin-left is "auto" ?
I want to read a pre tag with xml. I am working client side. I have tried everything. The <title> tag gets lost with innerHTML(ok in FF only). I tried traversing the dom and putting in the tag names but the title tag is ignored. I am trying to syntax highlight this. Everything works if I do not use certain html tags. How do I get raw text from the pre? The text would come from one of two sources, a server or inputted into a textarea by the user. It is dynamically placed in the div tag and then processed.
I have a database with information of my users, lets say their date of birth.
I want them to be able to go to my site, and login with a username and password, after which they get to see what their date of birth is (according to what's stored in the database).
I want to upload a textfile named "userinfo.txt" structured like: <username>;<password>;<date of birth>, for example: "johndoe";"johnpass";"1985-11-25" "marydoe";"marypass";"1986-02-12"
What's the javascript to have a "username/password" box popup, and when a valid name/pass was entered show the appropriate date of birth?
I use Microsoft.XMLDOM load() method to load an XML file into memory and display some elements in the browser.
However it apparently locks the file, since I get this error message whenever a Visual Basic application concurrently tries to add an element to the same XML file:
The process cannot access the file because it is being used by another process.
I would like not to lock this file, but open it in read-only mode instead. In fact the browser simply needs to read its content, it doesn't need to modify it at all. As a consequence there is no reason to lock it.
At the same time, I need to access it from the VB process.
I have an external file, TestVar.js with a single line. NewsA("This is a test.","test.pdf","TEST")
Within my HTML I wish to use the array variables from TestVar.js, but can't seem to get them loaded for use. The following is what I have, but doesn't work. If I directly place the NewsA array in the script instead of trying to call it from the js it works just the way I want it, but I really need the external file. What am I doing wrong? Code:
I want to pass parameters thru URL. I know how to pass. I am finding problem in reading the parameters. here is the [URL]. how to to read these parameters from URL using java script?
I'm trying to read a cookie that I've set with php with javascript. The cookie is for storing the username when logging in to a site. If the cookie has been set I want the focus in the inline popup to target the password field so that the user doesn't have to tab down from the username field of the login form.
The php script stores the cookie perfectly: if (isset($_POST['remember'])){ $expire = time()+60*60*24*30; setcookie("login_username", $username, $expire); echo $_COOKIE['login_username']; } else { if (isset($_COOKIE['login_username']) || isset($_COOKIE['password'])){ $expire = time()-3600; setcookie("login_username", "", $expire); }}
The javascript: if (targetfocus == 'login_username'){ alert(readCookie('login_username')); if (readCookie('login_username') == 'username'){ targetfocus = 'password'; }} $("#"+targetfocus).focus(); ... function readCookie(name) { var cookieName = name + "="; var cookieArray = document.cookie.split(';'); for (var i = 0; i < cookieArray.length; i++){ var cookie = cookieArray[i]; while (cookie.charAt(0)==' '){ cookie = cookie.substring(1,cookie.length); }if (cookie.indexOf(cookieName) == 0){ return cookie.substring(cookieName.length,cookie.length); }return null; }}
But when trying to read the cookie in the javascript code I receive null when I put an alert to the code. Why won't the javascript find the cookie? Is it because I'm running the site localhost on my laptop? Does that have an effect on cookies?
While writing a look up for internet terms script for a site, I found the script will not read the second value in this array, I could make wl[1] a null value but would like to know what is happening if possible. All of the other elements seem to be ok!
function search(){ wl = new Array() wl[0]="applet - An Applet is a small application etc"; wl[1]="Bug? - Null but why"; wl[2]="cgi - CGI or Common Gateway Interface allows etc"; wl[3]="browser - A Browser is etc."; myWord=document.theForm.txtWord.value; myWord = myWord.toLowerCase(); for(c=0; c < wl.length; c++){ currentWord = wl[c].split(" "); alert(c + " MyWord " + myWord); alert(c + " Current " + currentWord[c]);// The alert box = 'Current -' when wl[1] is read. } }//end of function
Does anyone know how - or better yet - have a sample of how to extract information from a meta tag in an HTML document's head tag using Javascipt?
I have looked at the DOM with Firefox - but it seems so long. I'd be really interested in a better way. If someone has the javascript for walking through the DOM, that would be cool too. I havn't built it yet.
ok so I know how to do substring to read everything before a certain phrase however is there a way to read everything after a certain phrase? Ex of what this script reads and doesent read
Alex was slain by dog
Bob was slain by cat
Alex & Bob = "Var CharName" My substring reads this in this line: Var Charname CharName = msg.substring(0, msg.indexOf(" was"))[code].....
so I'm interested in knowing if there's a way through javascript, php whatever to be able to read the pages current URL. For example when the page loads and knows the difference between www.mySite.com/ and www.mySite.com/#aboutI'm trying to find if there's a way to use the '#about' as a variable for a particular script instead of just it being dummy text on the end of the URL.