Jump to content

[SOLVED] One More Question - How To...


Lamez

Recommended Posts

Alright, once again sorry about my last post.

 

Now I want to make a drop down list in html, which I have done, and I set the values from 0 - 5

 

as my action can I make it where it is is value 1 redirect to another page, and the same with the other values, I am not sure on how to go about this.

I know I am going to have to write a IF statement. If you start the code I a can finish it.

 

thanks again!  ???

Link to comment
Share on other sites

ya like here is my drop down box:

<form id="sort" name="sort" method="post" action="action.php">
  <label>
  <select name="select">
    <option value="#">Sort By...</option>
    <option value="0">All Members</option>
    <option value="1">Username</option>
    <option value="2">Last Online</option>
    <option value="3">Online Only</option>
    <option value="4">Offline Only</option>
  </select>
  </label>
</form>

 

say they click All Members it the action will redirect them to the right page.

Link to comment
Share on other sites

This can be done easily in javascript,do a simple google search.

Anyway,this is my code,just as a pointer

html

  <select name="select" id = "link">
    <option value="#">Sort By...</option>
    <option value="0">All Members</option>
    <option value="1">Username</option>
    <option value="2">Last Online</option>
    <option value="3">Online Only</option>
    <option value="4">Offline Only</option>
  </select>

javascript

function goto()
{
    var link = document.getElementById("link").value;
    window.open(link);
}

Link to comment
Share on other sites

<?php

if (isset($_POST['sort'])){
   $sort = $_POST['sort'];
   
   if ($sort == '1') $url = "www.something.php";
   if ($sort == '2') $url = "www.somethingelse.php";
   //keep going like this
   
   header("Location: $url");
}

?>

<form id="sort" name="sort" method="post" action="action.php">
  <label>
  <select name="select">
    <option value="#">Sort By...</option>
    <option value="0">All Members</option>
    <option value="1">Username</option>
    <option value="2">Last Online</option>
    <option value="3">Online Only</option>
    <option value="4">Offline Only</option>
  </select>
  </label>
</form>

Link to comment
Share on other sites

I found this!

 

Thank you very much!

 

<html>
<head>
<title>test</title>

<script language="JavaScript">
<!--
function WinOpen() {
  var url=document.redirect.selection.value
  document.location.href=url

}

// -->
</script>


</head>
<body>

<form name="redirect">
<select name="selection">
    <option value="#">Sort By...</option>
    <option value="viewmembers.php">All Members</option>
    <option value="viewmembers.php?sort=username">Username</option>
    <option value="viewmembers.php?sort=last">Last Online</option>
    <option value="viewmembers.php?sort=online">Online Only</option>
    <option value="viewmembers.php?sort=offline">Offline Only</option>
  </select>
<input type=button value="Go!" onClick="WinOpen();">
</form>
</body>
</html>

 

http://www.java2s.com/Code/JavaScript/Form-Control/DropdownRedirectSubmit.htm

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.