Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript problem, HELP!

    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.

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    something like this perhaps?

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

  • #5
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It was something like that. But all that one gave me is UNDEFINED

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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> ');

  • #7
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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 Code:
    <?php
    echo '<a href="page.php?id='$_GET['id'] .'">'.$_GET['id'].'</a>';
    ?>

  • #8
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •