Jump to content

[SOLVED] javascritp and PHP: submit form


jr8rdt

Recommended Posts

I would like to have link on all my server_id and when I click it I should go to a new page carrying with me the id

this is what I did. and when I click on the id link I don't get anything ( the page was not redirected)

help!

 

 

SCRIPT language="JavaScript">

function submitform()

{

  document.myform.submit();

}

</SCRIPT>

 

include 'db_connect.php';

$query  = "SELECT * FROM server ORDER BY server_id";

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

    $id1 = "{$row['server_id']}";

 

echo "<tr>";

echo "<form name='send1' action='modify.php'>";

  echo "<input type='hidden' name='id1' value='$id1'>";

  echo " <td><a href='javascript: submitform()'> {$row['server_id']} </a></td>";

  echo "</form>";

 

Link to comment
https://forums.phpfreaks.com/topic/53799-solved-javascritp-and-php-submit-form/
Share on other sites

the code will display whole bunch of records with server_id (id) . I want to be able to click the server_id (id) and go to another php page carrying with me the server_id. so this is somewhat similar to submitting a form but instead of clicking a submit button I click the server_id (id). do I have to use onClick??

 

 

You can have this

     echo " <td><a href='modify.php?id1=$id1'> {$row['server_id']} [/url]</td>";

Instead of your whole form.

 

If you modify.php you can access the id1 in the super global _GET or _REQUEST variable

 

$_GET['id1']

$_REQUEST['id1']

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.