/    Sign up×
Community /Pin to ProfileBookmark

integrating javascript and php onclick function

I need help integrating javascript into a php file. I am trying to use onclick function to have to user go to another page once they select a radio button

I have never used javascript before so I need details on using the onclick function as it deal with my example.

code below

<html>
<head>
<script language=”JavaScript”>
</script>
</head>
<body>

<?php

$connection = @mysql_connect(“localhost”, “administrator”, “bulls23”)or die(mysql_error());

$result= @mysql_list_dbs($connection) or die(mysql_error());

echo “<b>select a Database</b><br >“;
while($row = mysql_fetch_array($result)) {
// echo “<input type=’radio’ name=’dbnames’ value=’$row[Database]’>$row[Database] <br>”;
echo ‘<input type=”radio” name=”dbnames” value=”‘ . $row[Database] . ‘” onclick=”window.location=info.htm?db=’ . $row[Database] . ‘”>’ . $row[Database] . ‘<br>’;
}

mysql_close($connection);

?>
</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rapathonykJul 22.2004 — just one detail about the array $row

i think u must put the string (Database) between '

then it seems u dont who to use the form tag, it's strange.. if i were u i would have wrote this like that:

[code=php]
$connection = @mysql_connect("localhost", "administrator", "bulls23")or die(mysql_error());
$result= @mysql_list_dbs($connection) or die(mysql_error());

echo "<b>select a Database</b><br >";
echo "<form method=get action=info.htm>";
while($row = mysql_fetch_array($result)) {
echo '<input type="radio" name="dbnames" value="' . $row[Database] . '" onclick="submit()">' . $row[Database] . '<br>';
}
[/code]


i hope this helps
×

Success!

Help @cedtech23 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.26,
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,
)...