Two simple website additions! but i'm stumped!

Soldato
Joined
10 Feb 2004
Posts
5,116
Location
Crewe, UK
Hey!

I have to add two pieces of code to an "Instant Store" website, within the little HTML sections that they provide!

The two things need are to allow a person to pick two options (radio buttons possibly, like red and cat) and depending on the answers route them to a certain page!

The other is to randomly pick a URL out of a list and forward the user onto that page!

I'm just a bit stumped on how to do it!

would anyone be able to help me out?

Thanks in Advance!

Rich
 
Soldato
OP
Joined
10 Feb 2004
Posts
5,116
Location
Crewe, UK
JustinW said:
You will probably need some JavaScript to do this? Are you able to write JavaScript?

Justin

'Fraid not, but I get that the first request I made is just a series of "IF" Statements, i've just never touched JavaScript before.

Rich
 
Associate
Joined
27 Dec 2005
Posts
97
Hi,

I was more getting at- will the instant store allow you to include JavaScript on the pages.

JavaScript is quite simple, take a look at W3 Schools for a tutorial on JavaScript.

Also, remember that JavaScript can be disabled by the client, so your customers can bypass it.

Justin
 
Soldato
OP
Joined
10 Feb 2004
Posts
5,116
Location
Crewe, UK
Alright!

I have got this far!

Code:
<html>
<body>

<script type="text/javascript">
if (radio_button.radio_young.checked and radio_button.radio_dry.checked)
{
function forward(){
location.href="YOUR YOUNG / DRY LINK HERE"
}
if (radio_button.radio_young.checked and radio_button.radio_normal.checked)
{
function forward(){
location.href="YOUR YOUNG / NORMAL LINK HERE"
}
if (radio_button.radio_young.checked and radio_button.radio_greasy.checked)
{
function forward(){
location.href="YOUR YOUNG / GREASY LINK HERE"
}
if (radio_button.radio_old.checked and radio_button.radio_dry.checked)
{
function forward(){
location.href="YOUR OLD / DRY LINK HERE"
}
if (radio_button.radio_old.checked and radio_button.radio_normal.checked)
{
function forward(){
location.href="YOUR OLD / NORMAL LINK HERE"
}
if (radio_button.radio_young.checked and radio_button.radio_dry.checked)
{
function forward(){
location.href="YOUR OLD / GREASY LINK HERE"
}
</script>
<form>
<input type="radio" value="Young" name="radio_young">Young
<br>
<input type="radio" value="Old" name="radio_old">Old
<br>
</form>
<form>
<input type="radio" value="Dry" name="radio_dry">Dry
<br>
<input type="radio" value="Normal" name="radio_normal">Normal
<br>
<input type="radio" value="Greasy" name="radio_greasy">Greasy
<br>
<input type="submit" value="Submit">
</form>

</body>
</html>

How do I get it to run when I click submit!!

I'm a bit stumped!

Rich
 
Associate
Joined
27 Dec 2005
Posts
97
Sorry, your JavaScript needs to be cleaned up a bit.

if (radio_button.radio_young.checked and radio_button.radio_dry.checked)
{
function forward(){
location.href="YOUR OLD / GREASY LINK HERE"
}

What you have done here is say IF the radio button is checked then define afunction called forward which will send you to this link.

The function forward never actually gets called. What you need to do is define your function 'forward()' like so:

function forward(url){
location.href=url;
}

Do this once only!

Then your if statements need to look like this:

if (radio_button.radio_young.checked and radio_button.radio_dry.checked)
{
forward("url here"){
}

You will need to define the function forward before it is called'.

Justin
 
Back
Top Bottom