Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Simple Script needed.

  1. #1
    Join Date
    May 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Simple Script needed.

    hello everyone ...i am looking for this script
    please help me i need this script


    For Example

    there should a form in which more than 100 website listed and there should be a button name "select random" when someone click on it then 1 website from this list should be open.

    Edit: You don't need to add URGENT to everything. That just increases your chance of the post being ignored/missed. Please use a more descriptive title next time. Thank you.
    Last edited by tech_support; 12-24-2007 at 07:13 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    #field1 {
    width:20em;
    font:95% arial, sans-serif;
    }
    #field1 p {
    margin-bottom:0;
    }
    </style>
    <script type="text/javascript">
    
    /* URL Picker ©2007 John Davenport Scheuer
     * This notice must remain for legal use */
    
    document.write('<style type="text/css">.noscript {display:none;}<\/style>');
    function grabUrl(f, r){
    if(!document.getElementsByName){
    alert('Your Browser is too old for this form!')
    return;
    }
    for (var e=document.getElementsByName('urlpick'), i = e.length-1; i > -1; --i)
    if((typeof r=='number'&& i==Math.floor(r*e.length))||(typeof r!='number'&&e[i].checked))
    f.reset(),e[i].checked=true,window.location=e[i].value;
    }
    </script>
    </head>
    <body>
    <div class="noscript">
    Javascript Required for the following form:
    </div>
    <form action="#" onsubmit="grabUrl(this);return false;">
    <fieldset id="field1">
    <legend>Pick Destination or hit "Go Random"</legend>
    <input type="radio" name="urlpick" value="http://www.google.com/">Google<br>
    <input type="radio" name="urlpick" value="http://www.yahoo.com/">Yahoo<br>
    <input type="radio" name="urlpick" value="http://www.dynamicdrive.com/">Dynamic Drive<br>
    <p><input type="submit" value="Go"> <input type="button" value="Go Random" onclick="grabUrl(this.form, Math.random());"></p>
    </fieldset></form>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks a lot mate:!

    does it possible to put this all link to be appear in a box like this one:

    http://www.proxies.name check this, there is a box i want to appear these links in a box.

    Thanks

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Hmm, that's not a form. You asked for a form. It could be adpted though:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    #thelinks {
    overflow:auto;
    width:15em;
    height:4em;
    font:95% arial,sans-serif;
    }
    </style>
    <script type="text/javascript">
    
    /* URL Picker ©2007 John Davenport Scheuer
     * This notice must remain for legal use */
    
    function grabUrl(){
    if(!document.getElementsByTagName){
    alert('Your Browser is too old for this!')
    return;
    }
    var e=document.getElementById('thelinks').getElementsByTagName('a');
    var r=Math.floor(Math.random()*e.length);
    window.location=e[r].href;
    }
    </script>
    </head>
    <body>
    
    <div id="thelinks">
    
    <a href="http://www.google.com/">Google</a><br>
    <a href="http://www.yahoo.com/">Yahoo</a><br>
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a><br>
    <a href="http://www.google.com/">Google</a><br>
    <a href="http://www.yahoo.com/">Yahoo</a><br>
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a><br>
    <a href="http://www.google.com/">Google</a><br>
    <a href="http://www.yahoo.com/">Yahoo</a><br>
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a><br>
    <a href="http://www.google.com/">Google</a><br>
    <a href="http://www.yahoo.com/">Yahoo</a><br>
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a><br>
    <a href="http://www.google.com/">Google</a><br>
    <a href="http://www.yahoo.com/">Yahoo</a><br>
    <a href="http://www.dynamicdrive.com/">Dynamic Drive</a><br>
    
    </div>
    <script type="text/javascript">
    document.write('<p><input type="button" value="Select Random" onclick="grabUrl();"><\/p>')
    </script>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    May 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    can you add a form in it please...like these all link should be in a form.
    take this example

    http://www.proxy.org

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm tiring of trying to hit a moving target. Also - I may be getting out of my depth, and/or you may not really know what you need/want or why.

    Let's try to clarify the situation. This latest example link of yours uses both server side and client side code, and is by no means, as your first post indicated in its title, a "Simple Script". I don't do much server side coding. But that might not be what you want and/or need, and/or can do with your host. If it isn't, you don't really need a form, and my last example would actually be better than a form because it allows normal use of the links for users without javascript enabled. It could be easily tweaked to open the links in a new window, and/or (perhaps not so easily) to do many other things on the client side.

    If you do need server side code for tracking purposes and/or to handle the URL loading from a select form element's options' values for users without javascript, I don't do that. But, if you already have a server side script that performs the desired tracking and whatever other functions you require of it, and a server that supports it, and if you know how that part of it works, I may still be able to help, but you would have to explain that part of it to me - what it does, and how it expects to be presented with what information.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    May 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you didnot understand why i mean...i just want to you to edit your code and do something that these links appear in a form.....will be very thankful to you.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Why do you want that? As I've already pointed out, unless you intend to use server side code with the form, the scrolling division from my last example is more accessible than a form would be.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    May 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok...i am now working with ur given script

    is it possbile to add a background color on only one link?

    and also:

    how to remove this scroller?

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What gives it a scrollbar is its style:

    Code:
    #thelinks {
    overflow:auto;
    width:15em;
    height:4em;
    font:95% arial,sans-serif;
    }
    The combination of a height that is less than the content and overflow auto gives a scrollbar. This would be useful for the 100 or so links that you say you want to use with it. However, with 100 or so links, you would probably want the height to be more, like 20em perhaps - so that more of the links would be visible at any given time (the scrolling section would be taller).

    If you really don't want it to have a scrollbar - have the full list presented all at once - remove the red parts from the above style.

    As for styling any individual links within the 'thelinks' division, this may be done in the normal manner via inline style, class or id selection.

    Example using inline style:

    Code:
    <a style="color:black;background-color:yellow;display:block;" href="http://www.google.com/">Google</a>
    Display block will extend the background color for the full line, and add a line-break, if you use it you would want to remove the <br> tag from the end of that line.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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