FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

How to add hyperlink to the Combobox elements

 


bukaida
I am trying to create a combo box, with pull-down items, whereby each entry is a hyperlink to a specified file. Can this be done using only html and does anyone know how to do it? If not, should I be tackling this in a different way?
Gushe
You Mean like a dropdown menu which links to a file? Smile


That's like this:

The HTML form:

Code:

<form>
<select id="menu" onchange="go()">
  <option>Choose File</option>
  <option value="Link to file 1">File 1</option>
  <option value="Link to file 2">File 2</option>
  <option value="Link to file 3">File 3</option>
</select>
</form


And add the following JavaScript function:

Code:

<script type="text/javascript">
function go()
{
window.location=document.getElementById("menu").value
}
</script>



Or do you mean something else? Smile


~Gushe
bukaida
Gushe wrote:
You Mean like a dropdown menu which links to a file? Smile


That's like this:

The HTML form:

Code:

<form>
<select id="menu" onchange="go()">
  <option>Choose File</option>
  <option value="Link to file 1">File 1</option>
  <option value="Link to file 2">File 2</option>
  <option value="Link to file 3">File 3</option>
</select>
</form


And add the following JavaScript function:

Code:

<script type="text/javascript">
function go()
{
window.location=document.getElementById("menu").value
}
</script>



Or do you mean something else? Smile


~Gushe


Thanks man.Thats exactly what i mean.I donot have any idea of java script.
One more small help please if possible--

I want to give a prompt to the user to enter the password when he tries to open the html file.
After successful entry of the password, the user should be able to see the file else he will again be directed to the password prompt.The password is hardcoded in the script.is it possible with javascript? Please help. Thanks in advance.I am using the following code but it is showing the page in the background.How to prevent it?
Code:

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
   function check()
   {

var x=0;
do
{
var name = prompt("Enter the password for normal document", "Type your password for normal document");
if (name == "admin")
   {
   alert("Hi " + name + "\nSuccessful Login");
   x=0;
   }
else
   {
   alert("wrong password, Please try again.");
   x=1;
   }
   }while(x>0)
}
</script>
</head>

<body bgcolor="#A5BDD8" onload="check()" >
Gushe
Ok; I'm only learning JS too Smile But I think I Eventually know something Smile


1. Make a new white internet page where there is nothing special to see and add the following script there:

Code:

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">

   function check()
   {

var x=1;

while (x>0)
{
var name = prompt("Enter the password for normal document:", "");
if (name == "admin")
   {
   alert("Hi " + name + "\nSuccessful Login");
   window.location="Page Link Here"
   x=0;
   }
else
   {
   alert("wrong password, Please try again.");
   x=1;
   }
 }
}
</script>
</head>

<body bgcolor="#A5BDD8" onload="check()" >


2. Do so; that the link that normally should redirect you users to the file page; links your users to the blanc page Smile
3. Where I put "Page Link Here" in the code; add the link of the file page Smile




How It works:

1. When a user want's to go to the file page; They get a white page with your password promt; If they enter the right password they will be redirected to the file page, if not, they will have to enter the password again Smile
Simple; but efficient.. (I think it works, couldn't test it Razz)


With the password hardcoding I can not help you, I'm sorry for that Smile I'm only a fourteen year old, silly boy who is learning some scripting Smile



Greetz,
~Gushe
sambhav
Great help dude.
Gushe
Glad I could help Smile


~Gushe
bukaida
Gr8 help dude.But the password is visible to everyone when typed.Can't it be substituted with * symbols like our normal password field?
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.