Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Immediate reaction from pulldown

Status
Not open for further replies.

Lochness30

Programmer
Jun 9, 2004
23
CA
Maybe this is easy and I'm retarded :) But I have a web site that has a pull down and then the user clicks the "Show Index" button underneith.

Is it possible to just immediately do the "Show Index" statement without them having to press the button. Ie run the command when they select and item from the pulldown.

If not doable in php, can a Javascript do it?

Thanks for any help.
 
You can refresh the page after something is selected and then let php deal with the resent information. Or you can do anything with the information through javascript. In any case, javascript does what you want (forum216).
 
I am not sure I understand what you are asking, but I think I have done what you are asking for.

I am assuming by "pull down" you mean select boxes (HTML tag <select name="">)

If that is the case you can use the onchange command. I made the value appear in a text box with CSS applied. You can modify the css to change the look, or remove it!:

Code:
<html>
 <head>
  <style>
   .textbox
    {
    font-color: red;
    font-family: verdana;
    font-weight: bold;
    font-size: 10px;
    border: 0;
    }
  </style>
 </head>
 <body>
  <form name="formname" action="action.php" method="post">

   <select name="selectname" onchange="JavaScript:document.formname.textboxname.value = document.formname.selectname.value;">
    <option value="index 1">INDEX ONE</option>
    <option value="index 2">INDEX TWO</option>
    <option value="index 3">INDEX THREE</option>
   </select>

   <br>

   <input type="text" name="textboxname" class="textbox">

  </form>
 </body>
</html>

You can also include: onkeydown="JavaScript: return false;" within the "<input type="text">" box to prevent people from changing the value.
 
That's something like I'm trying to do. I'm trying to make that "onchange" method issue a submit (like the button does). Here's my latest attempt.

Code:
<form action="" method="post" name="category" id="category">
  <select name="cCategory" onchange="javascript:document.theForm.submit();" id="cCategory">
    <option value="Reunion">Reunion</option>
    <option value="Heading Home">Heading Home</option>
    <option value="Baseball">Baseball</option>
  </select>
  <input type="submit" name="Submit" value="Show Index">
</form>

When I run it, it gives me an "error on page" message. But the submit button work normal (which I'm trying to get rid of). Am I close?

Thank for the reply!
 
FYI. Found out it was a simple HTML statement. The key was

Code:
onchange="this.form.submit();"

Anyone having the same problem, there's the solution!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top