Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Need Help With HTML

Author
Message
Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 22nd Apr 2007 20:40
Hello!

I use HTML to programme websites and I want to work out how you can make a form, so when you click a button, for example... "Gimme A Hamster Name" it will open a new random page with a hamster name, but if you go back and click it again, it will take you to a different page with a diferent name on. I found a website that does it if you don't understand what I mean its

http://www.coyoteslodge.com/hamform.htm

I'd be really pleased if someone could help me,

Ollie

Ollie
FINN MAN
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 22nd Apr 2007 20:45
HTML is not able to do this. You will need to learn some java script of PHP.

hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 22nd Apr 2007 20:47
You'd need to use PHP or something similar to do this. The easiest way to do this is to use PHP to create an array of names, and then just randomly choose one of those names from the list when they arrive at the page.

Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.
Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 22nd Apr 2007 21:01
Erm... thanks, how can I get started with PHP should I just... search it I guess...

Ollie
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 22nd Apr 2007 21:05
Javascript can also do that.

Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 22nd Apr 2007 21:24
So anyone know any specific ways of making a thingy that randomly generates a different answer (selected from a few) every time you click on it using Php?

For instance, if theres a button saying

Gimme A Hamster Name, when you click it it will either come up with
Harry
Dexter
or Scratchy etc. etc.

Thanks to everyone whos posted

Ollie
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 23rd Apr 2007 00:40
Head over to http://www.w3schools.com/ to learn all about web related stuff.

Quote: "So anyone know any specific ways of making a thingy that randomly generates a different answer (selected from a few) every time you click on it using Php?"


Yes.


Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.
Jeremiah
18
Years of Service
User Offline
Joined: 9th Sep 2006
Location:
Posted: 23rd Apr 2007 00:46
Go to http://www.Hotscripts.com, all sorts of cool little things
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 23rd Apr 2007 01:00
A nice tutorial on random phrases in javascript;

http://www.pageresource.com/jscript/jrandom.htm

or

http://webmaster.lycos.co.uk/tips/988980678/

or just google for 'javascript random phrase' - there are literally thousands of tutorials on how to do it.

Boo!
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Apr 2007 01:22 Edited at: 23rd Apr 2007 10:33
If you use PHP, ASP, or Perl you will need a CGI host that supports this.

If you use JavaScript it will run anywhere a HTML file can be run including free hosting.

The only reason to use a CGI is to access a database or some other file storage data. Mind you if you need to save the results in JavaScript you can always send the data to an e-mail address

To do waht you vant in JS you would need to hold a list of names in an array then when the user clicks the button pick a random number and show that name. Unlike CGI Java script won't need to launch a new page it can do it all client side on the same window and is much more efficient.

something like..

<HTML>
<HEAD>
<SCRIPT LANGUAGE = "JavaScript">
<!--HIDE
function namePicker()
{
var names = new Array("fred","bill","frodo")
myRnd = Math.floor(rnd % (0 - 2))
this.form.setName.value = names[myRnd]
}
//-->STOP HIDING-->
</SCRIPT><HEAD>

<BODY>
<FORM>
<INPUT TYPE="text" NAME="setName"><br><br>
<INPUT TYPE="button" VAULE="Click for a New Name" onClick="namePicker()">
</FORM>
</BODY>
</HTML>

That was out my head so it might need some debugging to work but I'd recommend this book if you need to learn: JavaScript for the World Wide Web (Visual Quickstart Guide) Ted Gesing, Jeremy Shneider
it rocks!

http://www.KumKie.com http://bulldog.servegame.com
Suicidal Sledder
20
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 23rd Apr 2007 02:25
havnt looked at the page so maybe im wrong but couldnt you just view the source of the original page and take the code from that site? Maybe u've tried but i think its possible...

hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 23rd Apr 2007 03:36
Nope, the source of that site is inaccessible because it's written as a CGI script. The source is on the webserver, and it just returns the HTML for the hamster name. It's the same thing with PHP, ASP, etc. You only get the HTML source, not the source for the file that actually outputs the HTML -- just like this forum.

Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 23rd Apr 2007 03:55
Yeah I suppose thats the downside of JavaScript someone can come along and rip off your work

http://www.KumKie.com http://bulldog.servegame.com
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Apr 2007 09:30
I don't think a Hamster name generator is a script thats hot to steal, so no worries using javascript.


Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 23rd Apr 2007 17:44
Thanks a lot this has been very useful especially hyritcher

Thnks

Ollie
Josh
21
Years of Service
User Offline
Joined: 7th Dec 2002
Location: Pompey, Great Britain =D
Posted: 23rd Apr 2007 20:34
The best way to learn HTML is via Microsoft FrontPage. Never use what it produces as a website, but you can learn the various parts of HTML very easily from it.

Then you'll eventually discover the entity we all LOVE called CSS.

Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 25th Apr 2007 00:00
Sorry to be a nusiance, but Hyritcher, thanks very much for the code snippet you gave me it helps a lot, but sometimes it seems to not work, if I add more names to it, is there anything else I should change? Or am I just be awkward? Lol,

Ollie
<^^^>

Ollie
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 25th Apr 2007 00:19
Yeah, you need to change the line that says $a=rand(0,4) to a higher number -- the second number needs to be one less than the amount of names in your array.

Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.
Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 25th Apr 2007 00:26
Thanks your wicked!
How did you reply so quickly!

Ollie
Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 26th Apr 2007 00:20
Is getting google ads really worth it?

Ollie
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Apr 2007 06:28
no ads are ever worth it. Just because its Google doesn't make it any better than any other adverts or other crappy search/tool bars.


GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 26th Apr 2007 07:33
Google ads may help you cover your hosting costs but they won't make you rich :/

http://www.KumKie.com http://bulldog.servegame.com
Ollie is my name
17
Years of Service
User Offline
Joined: 5th Mar 2007
Location: Derbyshire, Uk
Posted: 26th Apr 2007 19:55
how much on average a day do you make from google ads?

Ollie

Login to post a reply

Server time is: 2024-11-18 13:31:30
Your offset time is: 2024-11-18 13:31:30