Code: Select all
<?
db_connect("localhost", "BibleDB", "", "");
$getbooks = db_query("SELECT N.Book, N.BookTitle, C.Chapter,
C.ChapterNum
FROM BookNames N, BibleChapters C
WHERE N.Book=C.Book
ORDER BY N.Book, C.Chapter");
$getchapters = db_query("SELECT Chapter, ChapterNum
FROM BibleChapters
ORDER BY Chapter");
// Puts the 66 books into an <OPTION> statement
$BookListBox = db_list_box($getbooks, "Book", "BookTitle");
db_data_seek($getbooks, 0);
db_disconnect();
?>Code: Select all
<script language="JavaScript">
<!--
// For each book, create an array to hold the chapters.
// Each book array will be identified by the book number
<?
$bibleQU = db_fetch_array($getbooks);
while($bibleQU) { ?>
// Create the array
BookArray<? echo $bibleQUї'Book'] ?> = new Array();
BookArrayValue<? echo $bibleQUї'Book'] ?> = new Array();
<?
$i = 0;
$temp = $bibleQUї'Book']; ?>
// Populate the array
<? while($bibleQUї'Book'] == $temp) ?> <? {
$i++; ?>
BookArray<? echo $bibleQUї'Book'] ?>ї<? echo $i; ?>] = '<? echo $bibleQUї'Chapter'] ?>';
BookArrayValue<? echo $bibleQUї'Book'] ?>ї<? echo $i; ?>] = <? echo $bibleQUї'ChapterNum'] ?>;
<? $bibleQU = db_fetch_array($getbooks);
}
} ?>
// Function to populate the chapters for the book selected
function PopulateChapter() {
// Only process the function if the first item is not selected.
if (document.Passage.Book.selectedIndex != 0) {
// Find the book number
var ThisBook = document.Passage.Bookїdocument.Passage.Book.selectedIndex].value;
// Set the length of the chapters drop down equal to the length of the book's array
document.Passage.Chapter.length = eval("BookArray" + ThisBook + ".length");
// Put '---' as the first option in the chapter drop-down
document.Passage.Chapterї0].value = "";
document.Passage.Chapterї0].text = "---";
document. Passage.Chapterї0].selected = true;
// Loop through the book's array and populate the chapter drop down.
for (i=1; i<eval("BookArray" + ThisBook + ".length"); i++) {
document.Passage.Chapterїi].value = eval("BookArray" + ThisBook + "їi]");
document.Passage.Chapterїi].text = eval("BookArrayValue" + ThisBook + "їi]");
}
}
}
function VerifyChapter() {
if (document.Passage.Chapterїdocument.Passage.Chapter.selectedIndex].value == "") {
alert("Please choose a valid chapter.");
return false;
}
else {
document.Passage.submit();
}
}
//-->
</script>__________________
MitchKill
II Cor. 12:9
"For God so loved the world that he gave his only begotten Son, that whosoever believeth on him should not perish but have everlasting life." John 3:16