PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 21st, 2004, 08:24 PM
fozzyuw fozzyuw is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 8 fozzyuw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 15 sec
Reputation Power: 0
jump menu question

More of a HTML question than PHP but it deals with PHP so I thought I would post it here.

I have a script that displays the contents of of a table.

I want a drop down "jump menu" with (in this example) 3 options.

When choosing the option it basiclly calls the same page where my php script is located which take the value of the select form and uses it in a switch statement to determine which kind of query to display.

The options are how the table will look. A self designed 'web' style, alphabetical by last name and by first name.

Code:
<?
   echo "The value of display is: ".$display."<br>";
 ?>
 <form name="form1">
   <select name="display" onChange="MM_jumpMenu('parent',this,0)">
 	<option value="web" selected>Website Style</option>
 	  <option value="alphaL">Alpabetical(last name)</option>
 	  <option value="alphaF">Alpabetical(first name)</option>
 	</select>


What happens when I use this jump menu it uses the value in the options to use a the page to jump too.

I can get it to work by using a submit button, but I'm wondering how to do it just by the choice that a person chooses.

Thanks,
Fozzy

Reply With Quote
  #2  
Old July 22nd, 2004, 08:23 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Select Elements have an 'onchange' event.

You can handle that event by submiting your form when something changes. This is untested, but it would look something like this:

<select onchange="this.submit();">
...
...
</select>

this.submit may or may not work; you may have to reference your form manually such as: document.all.formname.submit();
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old July 22nd, 2004, 08:40 AM
fozzyuw fozzyuw is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 8 fozzyuw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 15 sec
Reputation Power: 0
Hmmm... I tried that but it doesn't seem to be working.

It seems jump menu doesn't change anything to PHP variables or something because I get an error...

Warning: Undefined variable: jump in C:\Program Files\Apache Group\Apache\root/jumpmenu.php on line 18

for this...

Code:
<?
    echo "The value of jump is: ".$jump."<br>";
  ?>


and I don't get it when I implement the method and action section of a form with the submit button.

I'm just wondering how to just remove that pesky submit button and just have it work off of 'onChange'.

Here's my full code.

Code:
<?
    echo "The value of jump is: ".$jump."<br>";
  ?>
  <form name="form1" >
    <select name="jump" onChange="document.all.form1.submit()">
      <option value="web" selected>Website Style</option>
        <option value="alphaL">Alpabetical(last name)</option>
        <option value="alphaF">Alpabetical(first name)</option>
      </select><br>    
  </form>
  
  <?
      echo "The value of normal is: ".$normal."<br>";
  ?>
  
  <form name="form2" method="post" action="jumpmenu.php">
      <select name="normal" onchange"">
        <option value="web" selected>Website Style</option>
        <option value="alphaL">Alpabetical(last name)</option>
        <option value="alphaF">Alpabetical(first name)</option>
      </select>
      <input type="submit" name="Submit" value="Submit">
  </form>


Cheers,
Fozzy

Reply With Quote
  #4  
Old July 22nd, 2004, 08:48 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Working Sample:
Code:
<form name="form1" id="form1" action="http://www.laidbak.net/" method="get">
  <select name="menu1" onchange="document.all.form1.submit();">
    <option selected="selected">Test1</option>
    <option>Test2</option>
  </select>
</form>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > jump menu question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway