/    Sign up×
Community /Pin to ProfileBookmark

I have to put an “onchange” event in database dropdown i.e when i select any element from database dropdown then corresponding table should be shown in dropdown menu,pLz help me i am in deep trouble.

See my code below:

i have two file.

(1) lib.php
(2)conn.php

See code of :lib.php” :-

/*
function : showlist fucntion is used for display the list
input : $abc = name of the drop down
$db_list = result set of the query
$value = value of the option
output : display string in the form of list (option)
*
/
function showlistindrop($name_dp, $result_list, $value,$location)
{
//
$aa = “<SELECT NAME=’$name_dp’ onchange=’pulldown_menu()’>”;

//
while($row = mysql_fetch_row($result_list))
{

if ($value==$row[0])
$aa .= “<option value='”.$location.”‘ selected>”.$row[0].”</option>”;
else
$aa .= “<option value='”.$location.”‘ >”.$row[0].”</option>”;
}

//
$aa .= “</SELECT>”;

//
return $aa;

}

See code of “conn.php” :-

<script language=”javascript”>
function pulldown_menu()
{
// Create a variable url to contain the value of the
// selected option from the the form named pulldown and variable selectname
var url = document.list.list_database.options[document.list.list_database.selectedIndex].value

// Re-direct the browser to the url value
window.location.href = url
}
</script>
<?

include(“lib.php”);

$connect=mysql_connect($_POST[“host”],$_POST[“user”],$_POST[“pass”]) or die(mysql_error());

$db_list = mysql_list_dbs($connect);

print “<form method=’post’ name=’list’ >”;

//
print showlistindrop(“list_database”, $db_list, $_POST[‘list_database’]);
print “<br><INPUT TYPE=submit value=’Save’>”;
//

if ($_POST[‘list_database’])
{

$result = mysql_list_tables($_POST[‘list_database’]);
print showlistindrop(“list_table”, $result, $_POST[‘list_table’]);

}

I shall be very thankful to you.

Thanks

Parveen ?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @parveen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...