How to use on-click

Hi, a little help, please. I have been using:

<tr bgcolor="#D4AAFF">
<td><input name="radiobutton" type="radio" 
value="" onclick="gotolink()">target name</td>
<td>purpose for target</td>
<td>username " "</td>
<td>password " "</td>
<td>secure?/ans " "</td>
<td>emailused " "</td>

in an html program to keep show passwords, click on the button and go to the url.

This BELOW code selects a record from a database table and updates the date visited and times visited.
I want to use the onclick here to go to the url also. Preformatted text

<!DOCTYPE><html><head><title>email menu</title></head>
<form name="form" method="post" action="">
//============== check connection
{echo "Can't Connect to mySQL:".mysqli_connect_error();}
{echo "Connected to mySQL</br>";}
//This creates the drop down box
echo "<select name= 'target'>";
echo '<option value="">'.'--- Select email account ---'.'</option>';
$query = mysqli_query($con,"SELECT target FROM lookuptbl");
$query_display = mysqli_query($con,"SELECT * FROM lookuptbl");
{echo "<option value='". $row['target']."'>".$row['target']
echo '</select>';

<input type="submit" name="submit" value="Submit"/> 

{echo "Can't Connect to mySQL:".mysqli_connect_error();}
$name = $_POST['target'];
$fetch="SELECT id, target, username, password, purpose, emailused,lastused, 
visitcount, saved FROM lookuptbl WHERE target = '".$name."'";
$result = mysqli_query($con,$fetch);
{echo "Error:".(mysqli_error($con));}

//display the table
// echo '<table border="1">'.'<tr>'.'<td bgcolor="#ccffff align="center">'. 'Email menu'. '</td>'.'</tr>';
echo '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'
<td bgcolor="#CFB53B align="center">'.'id'.'</td>'.'
<td bgcolor="#CFB53B align="center">'.'target'.'</td>'.'
<td bgcolor="#ccffff align="center">'.'username'.'</td>'.'
<td bgcolor="#ccffff align="center">'.'password'.'</td>'.'
<td bgcolor="#ccffff align="center">'.'purpose'. '</td>'.'
<td bgcolor="#ccffff align="center">'.'emailused'.'</td>'.'
<td bgcolor="#CFB53B align="center">'.'lastused'.'</td>'.'
<td bgcolor="#CFB53B align="center">'.'visitcount'. '</td>'.'
<td bgcolor="#CFB53B align="center">'.'saved' .'</td>'.'</tr>';
{echo ("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td>
echo '</table>'.'</td>'.'</tr>'.'</table>';

              $sql = "UPDATE lookuptbl SET visitcount=$visitcount + 1, lastused=NOW() , 
 WHERE target='$target'";
           if ($con->query($sql) === TRUE) { echo "Record updated successfully"; }
        else { echo "Error updating record: " . $con->error; }


Why not use an HTML a tag?

Do you mean like
<a href="whatever_is_selected">go to account</a>

That’s it!


Not much to explain, the user clicks on the <a> element and is sent to the URL which is in the href attribute.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.