populate a text field upon a dropdown change
Have a membership db and recordset with column FirstName, LastName and GHIN_number
On form dropdown, i have array, FirstName and LastName
When a member is signing up for a game, they go to this form and select their name for the dropdown array [FirstName LastName]
I want to populate a text field with their GHIN_number, based on their choice in the dropdown of their name.
Then when their choice is made and they click Submit, I want to insert the FirstName, LastName and GHIN_number into another db table called Saturday Game.
My current code for the dropdown
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
foreach($_POST as $key => $val) {
if(is_array($_POST[$key])) $_POST[$key] = implode(", ", $_POST[$key]);
}
}
?>
<?php $selected = explode(", ", ValidatedField("index_225","player1")); ?><form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label for="player1"><strong>Your Name:</strong></label>
<select name="player1[]" id="player1">
<option value="" selected="selected">Select From Dropdown</option>
<?php
do {
?>
<option value="<?php echo $row_rs_members['FirstName']?> <?php echo $row_rs_members['LastName']?>" <?php if(in_array($row_rs_members['FirstName']." ".$row_rs_members['LastName'], $selected)) echo("selected=\"selected\""); ?>><?php echo $row_rs_members['FirstName']?> <?php echo $row_rs_members['LastName']?></option>
<?php
} while ($row_rs_members = mysql_fetch_assoc($rs_members));
$rows = mysql_num_rows($rs_members);
if($rows > 0) {
mysql_data_seek($rs_members, 0);
$row_rs_members = mysql_fetch_assoc($rs_members);
}
?>
</select>
<?php
if (ValidatedField('index_225','index_225')) {
if ((strpos((",".ValidatedField("index_225","index_225").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span class="stylered">Name required</span>
<?php //WAFV_Conditional index.php index_225(1:)
}
}
}?>
<br />
<?php
if (ValidatedField('index_276','index_276')) {
if ((strpos((",".ValidatedField("index_276","index_276").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span class="stylered">You are already signed up for Saturday</span>
<?php //WAFV_Conditional index.php index_276(3:)
}
}
}?>
<br />
<label for="email1"><strong>Email Confirmation </strong></label>
<select name="email1" id="email1">
<option value="" <?php if (!(strcmp("", (ValidatedField("index_225","email1"))))) {echo "selected=\"selected\"";} ?>>Select your Name if you want an email confirmation</option>
<?php
do {
?>
<option value="<?php echo $row_rs_members['EmailAddress']?>"<?php if (!(strcmp($row_rs_members['EmailAddress'], (ValidatedField("index_225","email1"))))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_members['FirstName']; ?> <?php echo $row_rs_members['LastName']?> </option>
<?php
} while ($row_rs_members = mysql_fetch_assoc($rs_members));
$rows = mysql_num_rows($rs_members);
if($rows > 0) {
mysql_data_seek($rs_members, 0);
$row_rs_members = mysql_fetch_assoc($rs_members);
}
?>
</select>
<br />
<br />
<label for="tee1"><strong>Your Tee Choice:</strong></label>
<select name="tee1" id="tee1">
<option value="" selected="selected" <?php if (!(strcmp("", (ValidatedField("index_225","tee1"))))) {echo "selected=\"selected\"";} ?>>Select Your Tee</option>
<option value="Gold" <?php if (!(strcmp("Gold", (ValidatedField("index_225","tee1"))))) {echo "selected=\"selected\"";} ?>>Gold</option>
<option value="White" <?php if (!(strcmp("White", (ValidatedField("index_225","tee1"))))) {echo "selected=\"selected\"";} ?>>White</option>
<option value="Blue" <?php if (!(strcmp("Blue", (ValidatedField("index_225","tee1"))))) {echo "selected=\"selected\"";} ?>>Blue</option>
</select>
<?php
if (ValidatedField('index_225','index_225')) {
if ((strpos((",".ValidatedField("index_225","index_225").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span class="stylered">Tee Required</span>
<?php //WAFV_Conditional index.php index_225(2:)
}
}
}?>
<br />
<br />
<label for="pairing1"><strong>Pairing Request:</strong></label>
<textarea name="pairing1" id="pairing1" cols="45" rows="5"><?php echo(ValidatedField("index_225","pairing1")) ?></textarea>
<br />
<br />
<span><input type="submit" name="submit1" id="submit1" value="Submit Saturday Signup" /></span>
</form>
I don't have the text field, GHIN_number in the form since i am not sure how to populate it based on their choosing their name in the select field.
Also, how to get the array of FirstName and LastName to insert into two columns?