Javascript Syntext Question With String.fontcolor

Oct 6, 2005

I have a schedule web page that is a glorified big table. This table is broken by days of the week, and into 1 hour incraments. This schedule is based on Eastern Standard time. To make this schedule easier to read for people of various time zones, I wish to highlight the day of the week heading and the hour of the day. To do this, I am going to write a perl program that is linked to off the navigation, which will acquire the server time and date and then generate the schedule html with javascript inserted into it which has a variable set by the perl program with the server date and time.

My question deals with the javascript. I beleive I need to use the String.fontcolor method so that I can change the color of the heading text to be different then all the rest of the table. But, do I define this javascript variable in the head section of the html with the string.fontcolor in the table accessing that varible? This is where I am definatly in serious gray area as to how I would define or do this. I don't think the javascript I would have to drive would be great, a if statement in the day headings. Day equal, change the font color. Else, default font color. Time of day equal(hour).

View 2 Replies


ADVERTISEMENT

Trim String In Javascript

Jul 23, 2005

for all your javascript trimming needs...

function trim(inputString) {
if (typeof inputString != "string") return inputString;
return inputString
//clear leading spaces and empty lines
.replace(/^(s|
|
)*((.|
|
)*?)(s|
|
)*$/g,"$2")

//take consecutive spaces down to one
.replace(/(s(?!(
|
))(?=s))+/g,"")

//take consecutive lines breaks down to one
.replace(/(
|
)+/g,"

")

//remove spacing at the beginning of a line
.replace(/(
|
)s/g,"$1")

//remove spacing at the end of a line
.replace(/s(
|
)/g,"$1");
}

View 3 Replies View Related

String Manipulation In Javascript?

Jul 20, 2005

New to javascript and still getting my head around strings...

Consider the following line of code...

var path = location.pathname;

....after execution, the variable "path" contains something like
"file:///C:/Documents%20and%20Settings/user/Desktop/Test/fileread.htm"

How do I parse this down to "C:Documents and SettingsuserDesktopTest"
....or at least to "C:/Documents%20and%20Settings/user/Desktop/Test"

Is there a better function to retrieve the source folder containing the
current HTML document?

I need to know the path to the current folder to reference other files in
the same directory using a FileSystemObject.

View 5 Replies View Related

How To Seperate A String With JavaScript?

Sep 19, 2004

Date format:
2003/03/15 04:00
2003/12/13 12:00
2004/02/12 13:12
2001/04/22 21:24

How can I sort all this date by the latest using JavaScript?

View 1 Replies View Related

String Replace And Reg Exp In Javascript

Mar 31, 2006

I've a function like this: Code:

function submit_msg() {
if (egsd.value == 'yes') {
write_msg("<b>" + chatkeo.value + " : " + chatmsg.value + "</b><br />");
} else {
write_msg(chatkeo.value + " : " + chatmsg.value + "<br />");
}
chatmsg.value="";
}

Now I need to do some string replace in chatmsg.value, ie, I need to look for some piece of text in chatmsg.value, and in case they are present (there may be multiple occurences of the same), to replace them with something else. This is what I got by doing a google search: Code:

function replaceAll( str, from, to ) {
var idx = str.indexOf( from );

while ( idx > -1 ) {
str = str.replace( from, to );
idx = str.indexOf( from );
}
return str;}

chatmsg.value = replaceAll( chatmsg.value, "string to replace", "new string" );
And I place this second function just above the previous one. But it's not working. Any help friends?

View 1 Replies View Related

Compare String With Numbers In Javascript

Jul 23, 2005

if (123 > 33) will return true

and

if ("123" > 33) will return true

So my question is, if the above behaviors are the same?? If string is
a number, and compare with another number, it will be the same behavior as compare 2 numbers?

In this case, it is comparing 2 strings that are numbers, so they are
string comparisons here. correct?

if ("123" > "33") will return true

In this case, "33a" is not a number, that's why when it compare with
another number, it always return false. correct?

if ("33a" > 33) will return false...

View 3 Replies View Related

Storing A Javascript Variable In A Php String

Jul 7, 2006

I have the following javascript function:

<script type="text/javascript">
function HTMLEncode( text )
{
text = text.replace(/&/g, "&amp;") ;
text = text.replace(/"/g, "&quot;") ;
text = text.replace(/</g, "&lt;") ;
text = text.replace(/>/g, "&gt;") ;
text = text.replace(/'/g, "'") ;
return text ;
}
</script>

Now i want to store the content of 'text' in a php string. Is that possible?

View 2 Replies View Related

Internal String Storage In JavaScript?

Dec 14, 2006

Does anyone have a reputable reference about internal string storage in
JavaScript? (for some particular implementation I mean).

Say having 1,048,576 characters long string from the geometric
progression:

function generateLargeString() {
var s = 'a'
for (var i=1; i<21; ++i) {
s = s.concat(s);
}
return s;
}

- the internal size should be 2 mebibytes and not 1 (?) if strings are
indeed stored as Unicode 16-bit. From the other hand it would be
tempting for an engine developer do not spend extra bytes on ASCII
chars...

So does anyone know of any documented engine optimizations on the
matter? Would be expected on some engine to have the string from above
twice smaller than say

function generateLargeString() {
// 1200 ETHIOPIC SYLLABLE HA
var s = String.fromCharCode(0x1200);
for (var i=1; i<21; ++i) {
s = s.concat(s);
}
return s;
}

View 2 Replies View Related

Javascript .split() String Into Pairs Of Variables

Sep 4, 2006

The URL is similar to:
https://url.com/form.htm?string=p,val1*l,val2*m,val3*t,val4*d,val5

Within the form, I have the following statement:

<input type="hidden" name="string">With this statement, string should take the value "p,val1*l,val2*m,val3*t,val4*d,val5"

I'm having a problem with the following script:

View 1 Replies View Related

Problems Generating Javascript String Variables With Php..

Feb 14, 2005

i'm trying to create some javascript string variables using php. i'm running into a problem because some of the variables span multiple lines and this is causing a problem. here is a sample of what i'm trying to do:

var thetext1=new Array()
thetext1[0]="info for #1 goes here"
thetext1[1]="info for #2 goes here"
thetext1[2]="info for #3 goes here"

etc.... the array values are output from a mysql db using php and used for a script i have on my page.

the problem is some of my strings span multiple lines and end up making it look like:

thetext1[36]= "this is an example
of how some stuff spans
multiple lines"

Using the javascript console in firefox i see the problem is: "Error: unterminated string literal." I believe it is because the string I am trying to input is spanning multiple lines. any idea on how to fix this?

i'm using php/mysql to create these javascript variables so i have access to their functions. i tried doing this:
str_replace( "
", '', $row['text']);
to replace the newlines with nothing but they're still there.

any ideas on how to get around this?

View 3 Replies View Related

Javascript String Doesn't Have Trim Method ?

Jun 6, 2007

I was trying:

Code:

<script>
function testtrim(value) {
alert(value.trim());
}
testtrim("Alex ");
</script>

The javascript don't work, my firebugs says:[value.trim is not a function] how to simulate an trim function?

View 4 Replies View Related

Match Entire String (regular Expression & Javascript)

Jul 23, 2005

I'm trying to perform a very simple validation of user input. I
want to verify that the user entered a six-digit string consisting
entirely of numbers. So anything from 000000 to 999999 is considered
valid. The problem that I'm having is getting the validation to work on
the entire string. In other words, 000000 is okay but 000000000000 is
also returning as a match. Here's a quick code block...I have something
along these lines....

/*********************/
<html>
<body>
<INPUT name="txtNumberField" type="text" id="txtNumberField">
<INPUT onClick="fnTestNumberField()" id=Button1 type=button value="Test
Number!" name=btnTest>
<script language=javascript>
function fnTestNumberField()
{
var sNumberValue = document.getElementById("txtNumberField").value;

if (sNumberValue.match(/A[0-9]{6}z/))
{
alert("match");
} else {
alert("no match");
}
}
</script>
</body>
</html>
/******************/

That is failing when I enter 123456 into the textbox. Why, though? I
know I can replace...

if (sNumberValue.match(/A[0-9]{6}z/))

....with something like...

if (sNumberValue.length == 6 && sNumberValue.match(/[0-9]{6}/))

....or I could assign a maxlength to the input box, of course. The thing
is, I really want to know WHY the regular expression isn't responding
as I'd expect. Is there a syntax error somewhere in the code?

View 2 Replies View Related

JQuery :: Display The Result Of Ajax Call As Html String And Not Plain String?

Dec 25, 2010

I want to know if there is a way to return ajax call as html value and not plain text, ie all html formatting will be displayed.

My code:

<script src="jquery.js">
<script>
$(function()
{

[Code]....

String returned from webform4.aspx is html formatted but jquery displayed it as plain text. Is that anyway to display it as html string ?

View 3 Replies View Related

Converting Int To String - Variable To Concatenate It As A String To Find An Input Box

Jun 26, 2010

I have a for loop: Code: for( var i = 0; i < aInput.length; i++ ) I want to use this i variable to concatonate it as a string to find an input box

Code:
var j = i;
var qualname = "discountqualifier" + j;
qualname.toString();
if ( inputName == ( qualname ) )
{

Assuming I have a input box named discountqualifier0, discountqualifier1, discountqualifier2 etc...

View 4 Replies View Related

JQuery :: Display Unicode String In Textbox With Ncr String?

Dec 2, 2010

I have some jquery code like this:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1258" />

[code]....

View 1 Replies View Related

JQuery :: String In String An Branch Based On Found?

Oct 18, 2010

I need a simple, quick and efficient way to logically branch if I find a string is contained in another string in jquery Most other languages this can be resolved in one or two lines and it would be readable.

View 5 Replies View Related

If Statement To Check Whether String Is A String Is Returning False

Jan 25, 2011

I have a simple example below showing how when I pass in the value of the value attribute of option node, and then use if operator to check whether parameter is a string or not, even though it's a string, it converts it to false boolean and triggers the else statement rather than calling a function.callback should be a string so why is it saying otherwise?

View 3 Replies View Related

Convert String Into Array - Break Apart A String Into Characters

Jan 27, 2010

Is it possible to break apart a string into characters, be it a word or a sentence, and store each individual character in an array?

View 11 Replies View Related

Combine The Three Values Into A String, Create A Md5 Of The String, Then Call The Value ?

Sep 21, 2010

I have made a basic form, and I need to combine three values within my form, then create an md5 hash of this string.Then assign it to a hidden variable.My form is here...

Code:
<p>
<label for="firstname">First Name: </label>
<input id="firstname" type="text" name="firstname" /><br />[code]....

Or I have created a pastebin of it here, for easy reading: http://pastie.org/1171757.So I need to be able to combine the three values into a string, create a md5 of the string, then call the value of the string into a hidden value all before posting the form.

View 12 Replies View Related

Substring Or Trim The String - Equate The Selection Value To String "Select State" And Execute Alert Message?

Apr 19, 2010

I need help with substring or trim function in javascript. Find below my code. Selection holds the value Select State, and length of the string is 14. I need to equate the Selection value to string "Select State" and execute alert message.

function selected_item() {
if (Selection=="Select State")
alert("Select the State");[code]....

I tried this:

var state=Selection.substring(0,11); and then string would be equated to state variable. But it is not working.

View 9 Replies View Related

Replace Characters / Inner String From A String

Aug 13, 2011

How I would remove characters from a string if they are present?

For example lets say I wanted to remove c:/fakepath/ from the string c:/fakepath/DSF102.jpg and just leave the DSF102.jpg how would I got about this?

View 2 Replies View Related

Validation - From String - Check If Some Char In Textbox Contains One Of The Ones In String "allowedChars"

Jul 14, 2011

I have this, VB.Net code..how can i do exact same thing in javascript?

How to check if some char in textbox contains one of the ones in string "allowedChars"

View 4 Replies View Related

Modify String - Lowercase Letters And Uppercase Letters In A String And Then Swap Them

Jan 19, 2010

I am currently trying to build a new function in javascript that is supposed to handle a string of text. The idea is that it should find the lowercase letters and uppercase letters in a string and then swap them.

Meaning all lowercase letter becomes uppercase letter and vice versa.

So i am just asking if someone could point me in the right direction or give some tips. I've currently been reading about the toUpperCase(); and toLowerCase(); functions and i am fairly confident i know how to use them for switching, however i still need a way to find the lower , upper character in the string so i later can switch them.

View 5 Replies View Related

Use String.replace That Is Not Case Sensitive And Replace Every String Found?

Jul 27, 2010

Here is my code:

<script type="text/javascript">
var str="Welcome to Microsoft! Microsoft Microsoft";
var stringToBeFound = 'Microsoft'
var ReplaceString = 'site'
document.write(str.replace(stringToBeFound , ReplaceString ));
</script>

My problem is im trying to use string.replace that is not case sensitive and replace every string found. I could use regular expression with it but my stringToBeFound is a dynamic variable im getting it from my database

View 9 Replies View Related

Remove A String From Within A String

Jul 23, 2005

How can i remove a string from an existing string in javascript. I have a textbox in a form and want to make sure that when the user clicks a button that certain words are moved, like all instances of "hello" should be taken out of the text the user typed in the textbox.

View 3 Replies View Related

Dynamically Writing Html/javascript From A Javascript Function

Jul 23, 2005

I'm working on some code and am running into brick walls. I'm trying
to write out Javascript with Javascript and I've read the clj Meta FAQ
and didn't see the answer, read many similar posts (with no luck
though), and searched through the IRT.ORG Faqs
(www.irt.org/script/script.htm).

The Javascript is designed to open an popup window and then inside that
window call another script which will resize that window. There may be
another way around this but the reason I tried this approach initially
was that I wanted to call the onload handler in the popup window to
resize the image only after the image had completely loaded. I've had
some code in the primary Javascript file (showimage.js) before that
works if the image has been cached but on the first load, it doesn't
resize properly which tells me it is probably because it is trying to
resize the window based on the image size but it isn't completely known
at that point. So I removed that code and tried placing the resizing
code in the second Javascript file (resizewindow.js). BTW I've tried
other code to open a popup image and automatically size it ie Q1443 at
irt.org but that doesn't do exactly what we need.

Even if there is another way to do this with one file, I still want to
figure out why this isn't working in case I run into it in the future.

I thought what I would need to do to use document.writeln to write
Javascript would be to escape any special characters and to break
apart the script tag ie

document.writeln('</SCRIPT>');

would become

document.writeln('</SCR' + 'IPT>');

I have a HTML page and 2 Javascript files. All files are in the same
directory and have permissions set correctly.

Here are the 3 files (keep in mind wordwrap has jacked up the
formatting):

index.html
----------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1"
SRC="showimage.js">
</SCRIPT>
</head>

<body>
Click the house<BR>
<A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG
SRC="house1thumb.jpg"></A>
</body>
</html>


showimage.js
------------
function newWindow1(pic,sitename)
{

picWindow=window.open('','','width=25,height=25,sc rollbars=1,resizable=1');
picWindow.document.writeln('<html> <head>');
picWindow.document.writeln('<SCR' + 'IPT type="text/javascript"
LANGUAGE="JavaScript1.1" SRC="resizewindow.js"></SCR' + 'IPT>');
picWindow.document.writeln('</head>');
picWindow.document.writeln('<body onload="resizewindow();">');
picWindow.document.writeln('<img src=' + pic + '>');
picWindow.document.writeln('</body> </html>');
picWindow.document.close();
}

resizewindow.js
---------------
function resizewindow()
{
// Do resizing here.
// Right now this isn't being executed
alert("resizing window");
}


Can anyone provide some pointers as to why this javascript is failing?
I'm using IE6 on Win2k and when I click on the image to open the popup
window, it does open the window but it is white with no content and the
system immediately goes from about 4% CPU usage to 100% and
consistently stays there until I kill that window with the task
manager.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved