Re: Pass database id through href

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gavin Amm wrote:

EXAMPLE:
(I know you can't use "value" with the "a" tag, but bear with me for
illustration purposes in this pseudo-code)


<form name="theForm">


<input type="text" name="title">
<!-- etc with the fields -->

<input type=text name="formInput">
<a href="javascript:document.theForm.submit();" name="parent"
value="23">Auditing Home</a>
<a href="javascript:document.theForm.submit();" name="parent"
value="17">Finance Home</a>
<a href="javascript:document.theForm.submit();" name="parent"
value="122">Planning Home</a>
<a href="javascript:document.theForm.submit();" name="parent"
value="231">Tax Home</a>

</form>


When the admin clicks on one of the "parent" hyperlinks, the form is submitted with (in this example) (say they click on the "Tax Home" link) the values: $title == [whatever the user types into the text field] $parent == 231

How do I get this $parent value from the html page??

Instead of calling theForm.submit(), all another function that sets a form variable before submitting the form.


<a href="javascript:mysubmit(231);">Tax Home</a>

<script>
function mysubmit(var)
{
  document.theForm.parent.value = var;
  document.theForm.submit();
}
</script>

"parent" might be a reserved word, so watch out for that. I'm no JS wiz, but I think that's something along the lines of what you want to do. You basically use JS to add a form element based upon what link was clicked.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux