Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-01-2005, 07:48 PM   #1 (permalink)
trying
Registered User
 
Join Date: Feb 2005
Posts: 3
trying is on a distinguished road
HTML inside an array

I am sure that there is a simple way to "mark" or code say a link inside a javascript array.
daySchedule[2] = "Continue with Word 2003 Introduction at http://atomiclearning.com"

All I want to do is make the http://atomiclearning.com a real link not just words. I have tried a lot of things but I am not trying the correct thing! Thanks for your help.
trying is offline   Reply With Quote
Old 02-04-2005, 09:32 AM   #2 (permalink)
metazai
Regular Contributor
 
Join Date: Apr 2004
Location: Orange County, CA
Posts: 124
metazai is on a distinguished road
Not sure what you're trying to achieve . . .

Could you post more of your JavaScript, so we can see how you want the link to be displayed? It is possible to populate a variable with text that can then be displayed as html code (hence the link), but not if you are processing the variable arrays in a way that won't allow it.

In other words, post the script, if you can.
metazai is offline   Reply With Quote
Old 02-04-2005, 10:48 AM   #3 (permalink)
trying
Registered User
 
Join Date: Feb 2005
Posts: 3
trying is on a distinguished road
All of the code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language = "javascript" type="text/javascript">

<!-- Hide script from non-supporting browsers

daySchedule = new Array
daySchedule[1] = "Continue lessons in http://atomiclearning.com - username rmote password learn"
daySchedule[2] = "Cohen Bat Mitzvah: 9am - 2pm"
daySchedule[5] = "Friends of Poodles annual dinner and dog ball: 7 - 11pm"
daySchedule[7] = "Community Church Sacred Harp Singing: 7 - 10pm"
daySchedule[9] = "Carson/Kathilde Wedding: 7:30pm"
daySchedule[10] = "Jimmy Buffet Fan Club dinner dance: 6:30 - 11pm"
daySchedule[12] = "Tri-county Divorced Parents board meeting: 11am - 1pm"
daySchedule[14] = "Churchill's 10th Anniversary Bash 7pm - 2am"
daySchedule[17] = "Irish Singles St. Patrick's Day Dance: 7:30pm - midnight"
daySchedule[20] = "Girl Scout Troop #1379 Silent Auction: 6 - 8 pm"
daySchedule[24] = "Thomason/Kirshtein 10th Anniversary Party: 2 - 5 pm"
daySchedule[26] = "St. Mary's Elementary teacher in-service: 8:30am - 4 pm"
daySchedule[28] = "B. Mevitz Camp administrators meeting: Noon - 2:30 pm"
daySchedule[30] = "3rd Street Mission chili cook-off and gospel singing: 3pm - 10 pm"
function showDate(thisDay)
{
document.Calendar.dateInfo.value = daySchedule[thisDay]
}

// end hiding script -->
</script>

I had wanted to put a link inside the quotation marks that follow the daySchedule[].

Thanks for your help.
trying is offline   Reply With Quote
Old 02-04-2005, 12:50 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,711
redhead is on a distinguished road
Code:
daySchedule[1] = "Continue lessons in <a href=\"http://atomiclearning.com\">http://atomiclearning.com</a> - username rmote password learn"
??
Unless the document.Calendar.dateInfo.value is refering to an <input type=text> somewhere in the page, then it can't be done.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-04-2005, 01:39 PM   #5 (permalink)
metazai
Regular Contributor
 
Join Date: Apr 2004
Location: Orange County, CA
Posts: 124
metazai is on a distinguished road
Well, it just goes to show you . . . I came up with a complicated parser that will break open any line put in the array, pick out the http:// prefix, and automatically link the item for you, and Redhead comes along and just hardcodes it, which is the simpler fix if you're putting in the array elements yourself.

Bottom line . . . Redhead is absolutely right, especially about document.Calendar.dateInfo.value needing to not be a form element (links won't work directly within form elements).

At any rate, here's my extended solution, in case you're curious:

Code:
function showDate(thisDay)
{
var parts=daySchedule[thisDay].split(' ');
var i=0;
subpiece = new Array
for (var i=0; i<parts.length; i++) {
subpiece[i] = parts[i].substring(0,7);
if (subpiece[i] == "http://") {
parts[i]="<a href=\"" + parts[i] + "\">" + parts[i] + "</a>";
}}
daySchedule[1]=parts.join(' ');
document.Calendar.dateInfo.value = daySchedule[thisDay]
}
metazai is offline   Reply With Quote
Old 02-04-2005, 01:42 PM   #6 (permalink)
trying
Registered User
 
Join Date: Feb 2005
Posts: 3
trying is on a distinguished road
It does call <input=text> lower in the body of the page and it references the number in the brackets [1]. I am curious however because I am trying to learn how to do this!! Thank you so much.
trying is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple reverse programm silex Standard C, C++ 3 01-22-2005 08:03 AM
working with Array Goong MS Technologies ( ASP, VB, C#, .NET ) 3 07-22-2004 12:14 PM
breaking down an array from a form metazai PHP 12 07-09-2004 06:18 AM


All times are GMT -8. The time now is 08:07 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting