/    Sign up×
Community /Pin to ProfileBookmark

Newb script help needed

I’m pretty new to javascript at the mo, and alot of the time I’m copy/pasting scripts over that I can use.

I’m currently writing an automatic record writer that I can use at work to make my life easier.

here’s my work so far…
[URL=http://homepage.ntlworld.com/techie.tim/scripty1.html]http://homepage.ntlworld.com/techie.tim/scripty1.html[/URL]

Underneath the text box down the left hand side, I’ve written some signatures that can be added at the end of the record, however, what I really need is a way to store a single signature as a cookie, that can then be added on the end when pressing a button.

This will allow more people at my workplace to use the site, and not bog it down with too many buttons.

pleeze help me somebody???

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriDec 02.2003 — what you trying to do, looks like the signature thing is working atm or do you want it to automaticcally add signature by a cookie?, buttons could do with tidying up lol (thats sjust what id do)
Copy linkTweet thisAlerts:
@techietimauthorDec 02.2003 — Yeah! Don't worry, I have plans for the buttons.

The Signature buttons I have at the moment are there only temporarily. I basically want it so others can use the page without me having to do a new button for them each time.

The best way I can think of doing this is by allowing people to create thier sig by a cookie, and then having a single button that would add it to the bottom of the list.
Copy linkTweet thisAlerts:
@96turnerriDec 02.2003 — what about a button and on click opens a prompet

Please Enter Your Name

.................

Ok Cancel

??
Copy linkTweet thisAlerts:
@techietimauthorDec 02.2003 — That's ideal if it's going to set a cookie. but pointless otherwise, as I can just add the name manually at the bottom of the text area.
Copy linkTweet thisAlerts:
@96turnerriDec 02.2003 — [code=php]
<script type="text/javascript">

cookie_name = "dataCookie";
var YouEntered;

function putCookie() {

if(document.cookie != document.cookie)
{index = document.cookie.indexOf(cookie_name);}
else
{ index = -1;}

if (index == -1)
{
YouEntered=document.cf.cfd.value;
document.cookie=cookie_name+"="+YouEntered+"; expires=Monday, 04-Apr-2010 05:00:00 GMT";
}

}
</script>

<form name="cf">

Enter Your Name: <input type="text" name="cfd" size="10">
<input type="button" Value="Set to Cookie"
onClick="putCookie()">

</form>

<script type="text/javascript">

cookie_name = "dataCookie";
var YouWrote;

function getName() {
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
YouWrote = document.cookie.substring(namestart, nameend);
return YouWrote;
}
}
}
YouWrote=getName();

if (YouWrote == "dataCookie")
{YouWrote = "Nothing_Entered"}

</script>

<script type="text/javascript">
document.write("<textarea rows=10 cols=10 name=yourForm>"+YouWrote+"</textarea>")
</script>
[/code]
Copy linkTweet thisAlerts:
@techietimauthorDec 02.2003 — I'm having problems with this code.

I'm guessing that it's created the cookie ok, but how would I transfer it over to the text page, there's no button for that.

Also keep in mind that it needs to be added to the bottom of any text already in the field, and not replace it.

I haven't uploaded the page in case you're wondering.
Copy linkTweet thisAlerts:
@96turnerriDec 02.2003 — dont worry about uploading it, i will go to your site and get source and add in what i got and then give it to you, should be done arround, 10pm GMT (aprx 1h15m), gotta go out in a min so do it when get back

96
Copy linkTweet thisAlerts:
@techietimauthorDec 02.2003 — Thanks, you're a gem!

I'm trying hard to learn javascript, but my brain just cant get round some concepts!
Copy linkTweet thisAlerts:
@96turnerriDec 02.2003 — here i done the cookie bit just need to get it to write into yourForm textarea

96 let me know if ok

[upl-file uuid=86140214-caba-49b2-a988-8a0455ae6ff2 size=12kB]scripty1[1].txt[/upl-file]
Copy linkTweet thisAlerts:
@techietimauthorDec 02.2003 — Looking good, however...

It came up showing "tim" in the box (which is from some previous cookie fiddle I guess). I changed it to my signature, clicked the button, and it held whenever I hit the refresh key.

But when I clicked on "clear", it reverted back to "tim"

oh hang on, I see whats happening.

The cookie isn't accepting spaces in the signature. Is there any way round that?
Copy linkTweet thisAlerts:
@96turnerriDec 02.2003 — i cannot see why not accepting two words, tried it on mine doesa the same, going to bed now, look at it for you in morning? not desperate for it are you?
Copy linkTweet thisAlerts:
@techietimauthorDec 02.2003 — No, not absolutely despirate.

I've been working on this thing for ages, and I really appreciate the help you're giving me.

I'm completely in your hands.
×

Success!

Help @techietim 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...