| | |
dynamicly linked dropdown lists
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 42
Reputation:
Solved Threads: 0
Ok guys... I took the time to look over the posted solution... but I'm affraid I was not able to understand half of what was going on in there.
I fiddled around and came up with this simplistic example:
Now this works preatty well as it is... but it needs enhancing.
First of all, the option selected in the first list dosen't stay selected when the form reloads. I am transmitting the value and it's there when the form reloads via the get methode... but I haven't the slightest clue how to force the select object to target it after it has been repopulated. Any ideas?
Secondly. this example has the form only containing the dropdown lists. but I intend to use it in a form that will contain checkboxes too. well I don't want to loose the selected checkboxes when the form reloads... so is there a way in wich to put one form inside another?
Like:
<form1>
<form2>
code for dropdown lists and dropdown lists set with the onchange reload option
</form2>
code for checkboxes and submit button
</form1>
Or do I have to go and get all the values of any selected checkbox and send it through the link back to the beginning of the form and then re-select them?
and if so, the same question from the dropdown lists applies here... how do you force these objects to have a particular option set based on what data is beying transmited?
I would apreciate any feedback on this.
( Oh yes, and as a sidenote, it was pointed to me that the "joomla" is a stable and efficient designing enviroment for web based aplications. would it be advisable to use such an enviroment over notepad coding and development? )
I fiddled around and came up with this simplistic example:
PHP Syntax (Toggle Plain Text)
<html> <head> <title>Exemplu select</title> <script language="javascript"> function onchangeCounty() { document.form1.submit(); } </script> </head> <body> <?php $County1 = $_GET[County]; ?> <form name="form1" METHOD=get > County: <select name="County" onchange="onchangeCounty();"> <option value=""></option> <option value="name1">Name1</option> <option value="Name2">Name2</option> </select> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DBname", $con); $select="SELECT * FROM tablename WHERE Countyname='$County1'"; echo "<br>"; $result = mysql_query($select); echo "County:"; echo "<select>"; while($row = mysql_fetch_array($result)) { echo "<option>" . $row['Countyname'] . "</option>"; } echo "</select"; mysql_close($con); ?> </form> </body> </html>
Now this works preatty well as it is... but it needs enhancing.
First of all, the option selected in the first list dosen't stay selected when the form reloads. I am transmitting the value and it's there when the form reloads via the get methode... but I haven't the slightest clue how to force the select object to target it after it has been repopulated. Any ideas?
Secondly. this example has the form only containing the dropdown lists. but I intend to use it in a form that will contain checkboxes too. well I don't want to loose the selected checkboxes when the form reloads... so is there a way in wich to put one form inside another?
Like:
<form1>
<form2>
code for dropdown lists and dropdown lists set with the onchange reload option
</form2>
code for checkboxes and submit button
</form1>
Or do I have to go and get all the values of any selected checkbox and send it through the link back to the beginning of the form and then re-select them?
and if so, the same question from the dropdown lists applies here... how do you force these objects to have a particular option set based on what data is beying transmited?
I would apreciate any feedback on this.
( Oh yes, and as a sidenote, it was pointed to me that the "joomla" is a stable and efficient designing enviroment for web based aplications. would it be advisable to use such an enviroment over notepad coding and development? )
![]() |
Other Threads in the PHP Forum
- Previous Thread: rtf file convert to text format using php
- Next Thread: logout.php
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube





