View Full Version : Simple Script needed.
hicricket
12-23-2007, 03:47 PM
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.
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.
jscheuer1
12-23-2007, 06:50 PM
<!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>
hicricket
12-24-2007, 06:50 AM
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
jscheuer1
12-24-2007, 07:40 AM
Hmm, that's not a form. You asked for a form. It could be adpted though:
<!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>
hicricket
12-24-2007, 07:59 AM
can you add a form in it please...like these all link should be in a form.
take this example
http://www.proxy.org
jscheuer1
12-24-2007, 02:28 PM
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.
hicricket
12-24-2007, 02:51 PM
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.
jscheuer1
12-24-2007, 03:13 PM
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.
hicricket
12-24-2007, 03:21 PM
ok...i am now working with ur given script:D
is it possbile to add a background color on only one link?
and also:
how to remove this scroller?
jscheuer1
12-24-2007, 03:42 PM
What gives it a scrollbar is its style:
#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:
<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.
hicricket
12-24-2007, 03:47 PM
thanks alot:D
thats really working fine for me..i will ask for more help later..thanks again:D
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.