/    Sign up×
Community /Pin to ProfileBookmark

help with "to do list code"

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.

[code]
<SCRIPT LANGUAGE=”JavaScript”>
<!– Original: Pete Thompson ([email protected]) –>
<!– Web Site: [url]http://www.users.globalnet.co.uk/~thompp[/url] –>

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

<!– 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>
[/code]

i changed this part

[code]
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>”);
[/code]

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

to post a comment
JavaScript

25 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJul 10.2003 — I am presuming thats all you wanted it to do..Check it out

http://68.145.35.86/temp/metrosoccer12-ToDoList.html
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 10.2003 — 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.
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 10.2003 — 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">


???????????
Copy linkTweet thisAlerts:
@Khalid_AliJul 10.2003 — Re check th elink I posted above..?
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 10.2003 — 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.
Copy linkTweet thisAlerts:
@Khalid_AliJul 10.2003 — and then you want both values to be stored as to do lists????
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 10.2003 — yeah thats basicly what i want can it be done?
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 10.2003 — does any1 know or cant it be done?
Copy linkTweet thisAlerts:
@Khalid_AliJul 10.2003 — 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..?
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 10.2003 — okay i just thought it might go too far down the page and not be found
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 11.2003 — I'm getting the feeling that it cant be done.
Copy linkTweet thisAlerts:
@Khalid_AliJul 11.2003 — visit the link again posted above..I have made the necessary changes to the code. Njoy
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 11.2003 — thx so much!!!
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 11.2003 — 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 ([email protected]) -->

<!-- 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 [email][email protected][/email] //-->

<!-- 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?eleteItem(" + 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
Copy linkTweet thisAlerts:
@Khalid_AliJul 12.2003 — I have no idea wht are you trying to say..can you be a bit more clearer...
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 12.2003 — i added the "onclick" tag to the link, so it will also have an onclick function but it didnt work
Copy linkTweet thisAlerts:
@Khalid_AliJul 12.2003 — onclick added to where?..point to the code ...
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 12.2003 — code from page 1:


ShowCount++;

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

}
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 13.2003 — whats wrong with it?
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 14.2003 — i feel like this topic has been forgoten about ?
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 15.2003 — is everyone ignoring this?
Copy linkTweet thisAlerts:
@Khalid_AliJul 15.2003 — I know actually still have no idea what you are trying to do now...?
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 15.2003 — 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
Copy linkTweet thisAlerts:
@Khalid_AliJul 15.2003 — 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...
Copy linkTweet thisAlerts:
@metrosoccer12authorJul 16.2003 — 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.
×

Success!

Help @metrosoccer12 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...