/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] having a text box and then if you press a link it adds a number

Amazingly its hard to find a script that does this.

a text box
[ 0 ]

and when i click a link it adds a number to it

LINK (adds 4 for example)

[ 4 ]

another link (adds 11 to it)

[ 15 ]

i am finding it difficult, does anyone have knowledge of how to make this, thanks

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@bals28mjkSep 02.2007 — Well, where do you navigate to when you click the link?
Copy linkTweet thisAlerts:
@mitchellauthorSep 02.2007 — well i hope it can do it aswell as using my other script in one click this is the link i use.

<a href="RC2.html" onclick="return <a href="RC2.html" onclick="return parent.Resources.change(-14,-15,-16)" />Build- costs 14,15,16</a>[/QUOTE]

i plan if you have some code to add it to that and the box is in another frame so i can do the parent.Frame hopefully, thanks for replying

this is so when he updates something the "score" goes up.
Copy linkTweet thisAlerts:
@bals28mjkSep 02.2007 — So all you want to do is get data from another frame when the link is clicked and add it to a text box?

[CODE]parent.framename.objFuncVarName[/CODE]
So if you have a variable named "score" in your other frame, and want to update your text box just do:[CODE]
reftotextbox.value += parent.framename.thescore[/CODE]
Copy linkTweet thisAlerts:
@mitchellauthorSep 02.2007 — thanks for the help but that isnt what i whant althouh that has helped me a grate deal, i am after something so i have a text box in a frame called frame1.

<input type="text" id="Anything" readonly />[/QUOTE]

for now i would be very happy if so when i click a link which for now goes to "#null" for testing purposes would add a number to it which is specified in the link.

so in the link i could put 6 and so it adds that number to the box to it is bacicly like a calculator but just keeps on adding numbers i say in the links code.

this looks like it needs a script to do the adding which when i try to make it dosnt work
Copy linkTweet thisAlerts:
@bals28mjkSep 02.2007 — I'm having trouble understanding what you want. Post what you have so far and I'll help you fix it.
Copy linkTweet thisAlerts:
@mitchellauthorSep 02.2007 — hii, sorry about my explination i will try to explain.

all i want is a text box (with 0 to start) and a button and everytime you click the button it adds 5 to it, so i could click it 5 times and then 25 will be in the box.

that is the simple script i want and then i will be able to do all the frame stuff.

hope you can help.
Copy linkTweet thisAlerts:
@bals28mjkSep 02.2007 — Yes, that is a simple script.

  • 1. Create a form

  • 2. Create a function for the form in js

  • 3. Reference the value in the form with getElementById

  • 4. Add 5 to your referenced value


  • I want to see you at least attempt this, you won't learn as much if I were just to give you the code. If you get stuck or have a question about anything, don't be shy.
    ×

    Success!

    Help @mitchell 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,
    )...