The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Maybe someone can help.
I am making a form to submit events. I want to let the user select a country and from the country a dropdown "select" opens with the eithier state (US) Prov (CA) or Region. The countries are pulled form the database as are the states, provs, regions I want it to do this without reloading the page. here is what I have so far top of the page I have: Code:
<?php
$country = $state = null;
if(isset($_GET["country"]) && is_numeric($_GET["country"]))
{
$country = $_GET["country"];
}
if(isset($_GET["state"]) && is_numeric($_GET["state"]))
{
$state = $_GET["state"];
}
?>
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['events'];
formObject.submit();
}
</script>
name of event description of event date/time of the event City of the event (this is typed) Then I have this for country and state/prov/region Code:
<td><?php echo $lang['event_country'];?></td>
<td><select onChange="autoSubmit();" id="country" name="country" class="form_select" style="width:70%;">
<option value="null"></option>
<?php $fetch_countries = sql_query("SELECT * FROM countries");
while ($countries = mysql_fetch_array($fetch_countries)) {
echo ("<option value=\"$countries[country_id]\" " . ($country == $countries[country_id] ? "selected" : "") . ">$countries['country_name']</option>");
}
?>
</select></td>
</tr>
<tr>
<td><?php echo $lang['event_stateprov'];?></td>
<?php
if($country != null && is_numeric($country))
{
?>
<option value="null"></option>
<td><select name="stateprov" class="form_select" style="width:70%" onChange="autoSubmit();">
<option value="null"></option>
<?php
$fetch_stateprov = sql_query("SELECT state_id, state_name FROM states WHERE country_id = $country";
$statesprov = sql_query($fetch_stateprov);
while($stateprov = mysql_fetch_array($statesprov))
{
echo ("<option value=\"$stateprov[state_id]\" " . ($state == $stateprov["state_id"] ? "selected" : "") . ">$stateprov[state_name]</option>");
}
?>
</select>
<?php } ?>
Do you see anything wrong with the code and what can I add to not reload the page and populate the second drop down Thanks in advance! --------------- Added [DATE]1194314774[/DATE] at [TIME]1194314774[/TIME] --------------- I know i need to change the function , but I have no idea what to |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|