Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Simple help in JS needed
Old 11-08-2008, 07:41 PM Simple help in JS needed
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
Okay so i have this a web page with a lot of citations... but the page is continuesly edited, so i'd like as i add a new citation, all the numbers reevaluate themselves..
I thought i'd use a function like this
function myfunc()
{
var x;
document.write(x);
x++;
}

then for each citation put
<a href="#"><sup> myfunc() </sup> </a>

but it doesn't work... I've decided I need one of three things

1) Way to make html read javascript functions
2) Way to fix function (because it doesn't really seem to work)
3) Alternative way to accomplish this
THANKS IN ADVANCE!
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-09-2008, 06:30 AM Re: Simple help in JS needed
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
If I have understood your question, and the likelyhood is that I haven't at all

1) IMPOSSIBLE!

2) Unless the citations are produced in a way they can be identified (unique tag, class, or some other attribute on a tag) it won't happen.

3) USE SERVER SIDE CODE when it writes out the page, why on earth you would try to do something client side that would be obviously so simple to apply when creating the page on the server escapes me.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-09-2008, 10:13 AM Re: Simple help in JS needed
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
Thanks, and its because I'm not so skilled at PHP.
Basically this is what I want..
Let's say i have an article (1). And in this article I have many facts (2). So for each fact, i give i want to cite it and give a reference for it (3). Therefore at the end of each fact I add a little citation. The citation number links to the bottom of the page, where there is a quick source (4). This is similar to Wikipedia (5).

But now, lets say I want to add a sentance in-between 2 and 3, and make a citation for tht sentance. I would label it '3' but then I would need to go back, and relabel the old 3 as '4', the old 4 as '5' etc...
make sense?
so What i want to do is make it so that instead of just putting numbers, i have some sort of variable that adds one as it goes down the page. I thought to use like a javascript which first put the number then adds one...?

<?php
$number++;
echo $number;
?>

would that work?
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
Old 11-09-2008, 01:09 PM Re: Simple help in JS needed
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It might.

Without knowing the backend code for the site it's impossible to say.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-09-2008, 03:03 PM Re: Simple help in JS needed
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
Okay it worked perfectly... Thanks.
Now, for each of those citations I made them link to the bottom of the page with an ordered list... however i'd like to somehow make it so that
<a href="#1"> for the first one and <a href="#2"> for the second one etc... but it wont let me put php in the href or it just reads the php as if its PART of the url... If i could somehow just make it read the php as a number then put that after the # sign... at the bottom of the page I could have a bunch of anchors where there name = the same php equation.... so (1)'s href="#1" and then at the bottom of the page there is an anchor named "1" which it links to.... and so on and so forth down the page
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
Old 11-10-2008, 03:13 AM Re: Simple help in JS needed
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
give each of the elements IDs (server side) and make your citations named anchors to the IDs.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-10-2008, 11:47 AM Re: Simple help in JS needed
Skilled Talker

Posts: 68
Name: Avi Zolty
Location: Atlanta
Trades: 0
I thought of that but then I would not be able to add one in the middle without rescripting all the ones after... i figured it out, but thanks so much!

Liophant.com/stein.php

is the site, if you are interested in seeing how i managed to do it
Thanks again SO much!
Zoltar1992 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple help in JS needed
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45776 seconds with 12 queries