...

View Full Version : Javascript problem, HELP!



Horza
01-08-2004, 09:50 PM
Ok here is what i wrote at the webdeveloper.com Javascript forums. I had no answer.


Originally posted by Horza
Ok im looking for a javascript guru :)

Ive been working on a website for quite some time. Ive got a top100 running. (thats all the site is) And as you know, people can log hits in and out on most of them.

That is true of my one, but with a difference. People are given a link to vote for the site they submited which they can add to there site, with most Top100's. On my one (which i want to move it more towards a community or database) people are giving a <script etc..></script> which includes a file on my server which displays a small banner advertising the community.

The actual tag is,

<script type="text/javascript" src="http://www.gamerforums.org/linksite/test.php?ID=2"></script> <-- ID 2 for example.

On this banner i want to display a link saying 'Click to vote for this site.' And the link will "USE" the ID of the include to add it to the URL in the script file. So that the link will then go to the vote page of the Top100 for that Site-ID.

I dont know how to "USE" the ID. Ive been to plenty of websites like this with webmasters to help me. But they all told me how to do it but never explained how to use the Code they showed me. And it was using javascript functions i have never seen before.

Anyone who can help would have my eternal gratitude :) And i would give credit.

Garadon
01-08-2004, 10:32 PM
To my understanding of what ur saying clicking would take you to test.php, and if you have the usual php setup you would be able to access the variable $ID which would be equal to the value in the query ID.

so you just need to keep a database with ID's and Vote's then inc the vote for the corresponding send ID($ID). then the vote would have been registered and u can continue to the top100 page.

Such code could just as easily be written straigth into the top100 list file.

Horza
01-09-2004, 01:40 AM
no no no. I just need the script im accessing with the tag, with the ID variable in the URL.... to display a link with the same ID variable.

And PHP didnt want to work. Because it wants to read it as javascript.

Garadon
01-09-2004, 08:51 AM
something like this perhaps?

ID = document.location.href.split("ID=");
document.writeln('<a href="">'+ID[1]+'</a> ');

Horza
01-09-2004, 01:48 PM
It was something like that. But all that one gave me is UNDEFINED :(

Garadon
01-09-2004, 04:14 PM
how about this?

script tag:
<script src="t.php?ID=2" id="top100"></script>


and in the file referenced by the script tag:
ID =document.getElementById('top100').src.split("ID=");
document.writeln('<a href="">'+ID[1]+'</a> ');

Nightfire
01-09-2004, 04:38 PM
Next time read http://www.codingforums.com/postguide.htm Making note of section 2

What's wrong with php on a php page? It probably didn't work as you probably didn't code right.



<?php
echo '<a href="page.php?id='. $_GET['id'] .'">'.$_GET['id'].'</a>';
?>

Horza
01-09-2004, 04:56 PM
nightfire, Im new to this so yeh sorry.

anyway, like i sad before, php will not work in the file. Im pretty competant with php and i couldnt even get it to write a simple line of text from the file.


garadon. OMG I *************** LOVE YOU!

lol it worked. man you dont know how pleased i am! Ill drink in a beer in the pub to your name, CHEERS!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum