Click to See Complete Forum and Search --> : help with "to do list code"


metrosoccer12
07-09-2003, 06:26 PM
okay im using this to do list code im im not that good at javascript. I tried to add a thing where one of the field values in the form shows when u use it heres the code im using.


<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Pete Thompson (thompp@globalnet.co.uk) -->
<!-- Web Site: http://www.users.globalnet.co.uk/~thompp -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
var ShowCount = 0;
var SwapColour;
function ListToDoItems() {
var NumToDoItems = GetCookie('PT_NumToDoList');
var i;
var ToDoItem;
if (NumToDoItems == null) {
NumToDoItems = 0;
}
ShowCount = 0; SwapColour = 0;
for (i=1; i <= NumToDoItems; i++) {
ToDoItem = GetCookie('PT_ToDoItem'+i);
if (ToDoItem != null) {
PrintItem(ToDoItem, i);
}
}
}
function DeleteItem(Count) {
DeleteCookie('PT_ToDoItem'+Count);
window.location = window.location;
}
function PrintItem (ToDoItem, Count) {
var color = "";
SwapColour = 1 - SwapColour;
if (SwapColour==1) {color = "bgcolor='#c0c0c0'"} ;
ShowCount++;
var text = document.form.text.value;
document.write("<a href=" + text + ">" + ToDoItem + "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
document.write(""+"<a href='javascript:DeleteItem(" + Count + ")'>Delete</a><br>");
}
function AddItem() {
var NumToDoItems = GetCookie('PT_NumToDoList');
var i;
var ToDoItem;
if (NumToDoItems == null) {
NumToDoItems = 0;
}
ToDoItem = prompt("Enter new item");
if ((ToDoItem != null) && (ToDoItem != "undefined" )) {
NumToDoItems++;
SetCookie('PT_ToDoItem'+NumToDoItems, ToDoItem, exp);
SetCookie('PT_NumToDoList',NumToDoItems, exp);
window.location = window.location;
}
}
function set() {
VisitorName = prompt("Who are you?");
SetCookie ('VisitorName', VisitorName, exp);
SetCookie ('WWHCount', 0, exp);
SetCookie ('WWhenH', 0, exp);
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
// End -->
</script>

</HEAD>

<BODY>
<SCRIPT LANGUAGE="JavaScript">
ListToDoItems();
</SCRIPT><br>
<a href="javascript:AddItem()">Add Item</a>
<form name="form">
<input type="text" name="text" value="text">
</form>


i changed this part


var text = document.form.text.value;
document.write("<a href=" + text + ">" + ToDoItem + "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
document.write(""+"<a href='javascript:DeleteItem(" + Count + ")'>Delete</a><br>");


i really cant see why its not working can anyone help?

Khalid Ali
07-09-2003, 09:03 PM
I am presuming thats all you wanted it to do..Check it out

http://68.145.35.86/temp/metrosoccer12-ToDoList.html

metrosoccer12
07-09-2003, 09:24 PM
thx a lot, but now the only problem is i can only have like 1 item, i try to add another and it overwrites the old one.

metrosoccer12
07-09-2003, 09:29 PM
ok i think i was a little mis understood, i could of want the field as like a second type in thing, so if some1 types in like "hey" in the box it will be like <a href="hey">


???????????

Khalid Ali
07-09-2003, 09:47 PM
Re check th elink I posted above..:D

metrosoccer12
07-10-2003, 06:30 AM
but what i'm trying to say is, i want someone to be able to type in lets say there website address in the text field, and then type there name, in the box that pops up.

Khalid Ali
07-10-2003, 08:50 AM
and then you want both values to be stored as to do lists????

metrosoccer12
07-10-2003, 08:55 AM
yeah thats basicly what i want can it be done?

metrosoccer12
07-10-2003, 11:07 AM
does any1 know or cant it be done?

Khalid Ali
07-10-2003, 01:08 PM
Bepatient buddy,people who respond here are volunteers,since I have been working on this with you I'll get to it as soon as I can..so relax..:D

metrosoccer12
07-10-2003, 01:58 PM
okay i just thought it might go too far down the page and not be found

metrosoccer12
07-10-2003, 08:05 PM
I'm getting the feeling that it cant be done.

Khalid Ali
07-11-2003, 08:47 AM
visit the link again posted above..I have made the necessary changes to the code. Njoy

metrosoccer12
07-11-2003, 04:01 PM
thx so much!!!

metrosoccer12
07-11-2003, 04:15 PM
okay once again i need help lol, i tryed chaning stuff around but it doesnt work:


<script>
function play(songs){
sound1.src=songs
}

function stop(){
sound1.src=""
}

</script>
<bgsound id="sound1">
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Pete Thompson (thompp@globalnet.co.uk) -->
<!-- Web Site: http://www.users.globalnet.co.uk/~thompp -->
<!-- Updated code to append url(text field value) with the user input from propt box //-->
<!-- by Khalid Ali - July9,2003 k_ali@shaw.ca //-->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var expDays = 30;
//var todolistData = "";
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
var ShowCount = 0;
var SwapColour;

function ListToDoItems() {
var NumToDoItems = GetCookie('PT_NumToDoList');
var i;
var ToDoItem;
if (NumToDoItems == null) {
NumToDoItems = 0;
}
ShowCount = 0; SwapColour = 0;
var listOfItems = "";
for (i=1; i <= NumToDoItems; i++) {
var ToDoItems = GetCookie('PT_ToDoItem'+i);
//alert(ToDoItems)
if (ToDoItems != null) {
listOfItems += PrintItem(ToDoItems.split(','), i);
}
}
document.getElementById("toDoList").innerHTML = "";
document.getElementById("toDoList").innerHTML = listOfItems;
}

function DeleteItem(Count) {
DeleteCookie('PT_ToDoItem'+Count);
window.location = window.location;
}

function PrintItem (ToDoItems, Count) {
var color = "";
SwapColour = 1 - SwapColour;
if (SwapColour==1) {color = "bgcolor='#c0c0c0'"} ;
ShowCount++;
return "<a href='#' onclick='play(" + ToDoItems[0] + ");'>" + ToDoItems[1] + "</a> &nbsp;&nbsp;<a href='javascript:DeleteItem(" + Count + ")'>Delete</a><br/>";
}

function AddItem() {
var NumToDoItems = GetCookie('PT_NumToDoList');
var url = document.form1.text1.value;
var i;
var ToDoItem;
if (NumToDoItems == null) {
NumToDoItems = 0;
}
var temp = document.form1.text1.value;
temp += "," + prompt("Enter new item");
if ((temp != null) && (temp != "undefined" )) {
NumToDoItems++;
SetCookie('PT_ToDoItem'+NumToDoItems, temp, exp);
SetCookie('PT_NumToDoList',NumToDoItems, exp);
ListToDoItems();
}
}

function set() {
VisitorName = prompt("Who are you?");
SetCookie ('VisitorName', VisitorName, exp);
SetCookie ('WWHCount', 0, exp);
SetCookie ('WWhenH', 0, exp);
}

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
// End -->
</script>

</HEAD>

<BODY onload="ListToDoItems();">
<a href="javascript:AddItem()">Add Item</a>
<form name="form1">
Enter URL here &nbsp:&nbsp;<input type="text" name="text1" value="text">
</form><br/>
<div id="toDoList"></div>

i changed to change the url thing around and the onclick wont work can u help

Khalid Ali
07-11-2003, 11:29 PM
I have no idea wht are you trying to say..can you be a bit more clearer...

metrosoccer12
07-12-2003, 11:33 AM
i added the "onclick" tag to the link, so it will also have an onclick function but it didnt work

Khalid Ali
07-12-2003, 11:43 AM
onclick added to where?..point to the code ...

metrosoccer12
07-12-2003, 12:53 PM
code from page 1:


ShowCount++;
return "<a href='#' onclick='play(" + ToDoItems[0] + ");'>" + ToDoItems[1] + "</a> <a href='javascripteleteItem(" + Count + ")'>Delete</a><br/>";
}

metrosoccer12
07-13-2003, 04:00 PM
whats wrong with it?

metrosoccer12
07-14-2003, 10:31 AM
i feel like this topic has been forgoten about :(

metrosoccer12
07-15-2003, 08:04 AM
is everyone ignoring this?

Khalid Ali
07-15-2003, 09:43 AM
I know actually still have no idea what you are trying to do now...:D

metrosoccer12
07-15-2003, 02:54 PM
well when u did that code that worked great, u know how u made it when they type in the url in the box it makes a link, well i edited the link it was like this:

"<a href='#' onclick='play(" + ToDoItems[0] + ");'>


see i added the onclick tag but it doesnt work

Khalid Ali
07-15-2003, 05:08 PM
you have to tell me whats this Play function and whats the value in the ToDoItems[0]

and if it did work what should it be doing...

metrosoccer12
07-15-2003, 07:57 PM
im trying to combine the "to do list" with this:

http://forums.webdeveloper.com/showthread.php?threadid=12685

i would have told u at the start, but i wasnt sure how i was going to do it.