0

hi

i am creating a webpage with a menu down the left hand side. depending on which link in the menu you click a table on the right of will show the relavent information. the table will show the relavent information from a mysql table based on the link clicked.

i have found that i can do this using javascript. my form looks like this:

<form name="form" method="post" action="processpage.php" >
                <li> <h3> links</h3>
                    <ul>
                        <li><a name="link1" href="javascript&#058; void(1);" onClick="submitForm('link1');">like1</a></li>

this javascript code submits the form to the process page:

function submitform()
            {
                document.form.submit();
            }

but on the process page i do to make sure the link that is being clicked a passed to the process page: <?php print $_POST["form"]; ?>

put it doesnt print anything i get an error:

Notice: Undefined index: submit in C:\wamp\www\processpage.php on line 31

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by ryan1987
0

Try this and in your php look for "myvar"

<form name="form" method="post" action="processpage.php" >
<li> <h3> links</h3>
<ul>
<li><a name="link1" href="javascript: void(1);" onClick="submitForm('link1');">like1</a></li>
<input type="hidden" name="myvar" id="myvar" />
</form>
<script>
function submitform(txt)
{
    document.getElementById("myvar").value = txt;
    document.form.submit();
}
</script>
0

nothing happened when I clicked on the link.

I changed the href bit to: href="javascript:submitform(); and then something happened. I know get the word: undefined on the php page. i did this code on the php page:

<?php
		print $_POST["myvar"];
?>

any ideas to fix this error?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.