Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 10th, 2008, 03:50 PM
Authorized User
Join Date: Nov 2007
Location: , , Ireland.
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Hughesie78
Default PHP dropdown list

I am a newcomer to PHP from a asp.net
I have 2 dropdown lists on my page, the first ia hard coded with 3 values, once selected I want the 2nd dropdown list to be populated based on whats selected in the first, the second list is to be populated from a mysql DB, I want to change the SQL command for it based on the option value selected in the first list. help please, i know code is messy, have been looking forums piecing together... any ideas please or even a simple example to steer me in the right direction!!
here is my code which sits in the form:

                <td>Function Type:</td>
                <td><select name="cat" onchange="return reload(this)">
                            <option value="">--------Select--------</option>
                            <option value="1" text="Hardware">Hardware</option>
                            <option value="2">Stationery</option>
                            <option value="3">System Module</option>

                <select name="select_subcat">
                <?php $cat=$HTTP_GET_VARS['select_fxn'];?>
                <option value="" onchange=\"return reload(this.form)\">--------Select--------</option>


My Javascript:
function reload(thisform)
    var val=document.forms['frm_regbarcode'].cat.options[document.forms['frm_regbarcode'].cat.options.selectedIndex].value;
self.location='ch_test.php?cat=' + val ;
// return true;

// return true;

function reload3(form)
    var val=document.forms['frm_regbarcode'].cat.options[document.forms['frm_regbarcode'].cat.options.selectedIndex].value;
var val2=document.forms['frm_regbarcode'].select_subcat.options[document.forms['frm_regbarcode'].select_subcat.options.selectedIndex].value;

self.location='ch_test.php?cat=' + val + '&select_subcat=' + val2 ;
Thank You
Reply With Quote
  #2 (permalink)  
Old September 25th, 2008, 01:15 AM
Friend of Wrox
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 481
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran

hi mate,
try to use basic ajax script for this

(Anything is Possible)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown list maha .NET Framework 2.0 7 April 28th, 2007 12:32 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
HELP WITH DROPDOWN LIST enavas Excel VBA 1 April 6th, 2004 02:08 PM

All times are GMT -4. The time now is 09:31 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.