/    Sign up×
Community /Pin to ProfileBookmark

php and javascript array problem

this is almost working when i select an email it shows the name field but it shows more than one name on select as the php echo array returns more than 1 value how can i get it working to show the correct name only? The problem seems to be in defining the “names” in the <script> area!

<?PHP
include(“../checkadminlogin.php”);
include(“../../global/connection.php”);

$sql = “select intNameID, email,fname, lname, place from tbladvisorsdetails where place=’A’ order by intNameID ASC”;
$temps01=$DB_site->query($sql);
while ($row=$DB_site->fetch_array($temps01))
{
$selected = ($nameid==$row[“intNameID”]) ? ‘ selected=”selected”‘ : ”;
$email_options .= ” <option value=”{$row[‘intNameID’]}”$selected>{$row[’email’]}</option>n”;
$js_names_array .= “names[{$row[‘intNameID’]}] = ‘{$row[‘fname’]} {$row[‘lname’]}’;n”;
}
?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>APA</title>
<link rel=”stylesheet” type=”text/css” href=”office.css” />
<script type=”text/javascript”>
var names = new Array();
<?php echo $js_names_array; ?>

function changeName(value) {
document.getElementById(‘USEDname’).value = (names);
}
</script>

</head>

<body>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@shadiadiauthorDec 14.2008 — don't worry about this it has been solved
×

Success!

Help @shadiadi 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...