Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-02-2012, 04:55 PM   PM User | #1
janvw3333
New to the CF scene

 
Join Date: Jan 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
janvw3333 is an unknown quantity at this point
code html linking

I’m looking for a certain script.

On a page there is a text input field where the user can put a given code in. That code is linked to an html link. When a user puts the given code in, and presses a submitbutton, she is automaticly directed to the htmllink in a blank page.

In the html file there must be a easy way to edit the list below and the ability to add or remove Code/htmllinks:

A Code: HTMLlink
303033 http://www.link.com/link1
102222 http://www.link.com/link2
440000 http://www.link.com/link3

Does anyone know a script or how to do this?

Thank you in advance,

Jan
janvw3333 is offline   Reply With Quote
Old 01-02-2012, 05:25 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
it would seem to make more sense to me to make it a select box (to avoid people misentering the code), but then maybe you want to keep the options "secret" (which they won't be with javascript/html, but anyway...). here are both approaches - you can see which you like:

Code:
<html>
<head>
<title></title>

<script type="text/javascript">

function reDirect(choice){

switch (choice){
case "303033":
window.open("http://www.google.com")
break;
case "102222":
window.open("http://www.yahoo.com")
break;
case "440000":
window.open("http://www.codingforums.com")
break;
}

}
</script>
</head>
<body>
<select onchange="reDirect(this.value)">
<option >select code</option>
<option value="303033">303033</option>
<option value="102222">102222</option>
<option value="440000">440000</option>
</select>

Input code: <input id="tb" type="text"/><input type="button" value="go to page" onclick="reDirect(document.getElementById('tb').value)"/>
</body>
</html>
xelawho is offline   Reply With Quote
Users who have thanked xelawho for this post:
janvw3333 (01-03-2012)
Old 01-03-2012, 02:57 PM   PM User | #3
janvw3333
New to the CF scene

 
Join Date: Jan 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
janvw3333 is an unknown quantity at this point
Xelawho,

Thanks for the reply, it is very usefull.

greetings,
Jan
janvw3333 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:37 PM.


Advertisement
Log in to turn off these ads.