...

View Full Version : code html linking



janvw3333
01-02-2012, 05:55 PM
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

xelawho
01-02-2012, 06:25 PM
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:



<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>

janvw3333
01-03-2012, 03:57 PM
Xelawho,

Thanks for the reply, it is very usefull.

greetings,
Jan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum