RE: [PHP-DB] Pass database id through href

2004-04-14 Thread Gavin Amm
Thanks John,

Pointed me in the right direction.
This was the actual code I ended up needing.

(! Ignore this e-mail if it will offend you containing JavaScript info
rather than php/db info; I did need to figure this out for my db to be
updated appropriately...)

(1st you need to define the variable as a hidden field in the form)


(2nd, we need to use both the href attribute as well as, and separately
to, the onClick JavaScript reference, so the html output looks like:)
Me

The onClick event changes the value of the hidden field, the href
attribute submits the form with the submit() function.

I couldn't get it to work by calling a function, because the onClick
reference needed to be associated with that anchor tag and needed to be
a separate event to the href pointing to the submit() function.
I guess I could have 2 separate functions for each... But since it's
generated by the php script is easy enough like this.

Cheers,
Gav


-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 14 April 2004 12:48 PM
To: Gavin Amm
Cc: PHP-mailist
Subject: Re: [PHP-DB] Pass database id through href


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)
> 
> 
> 
> 
> 
> 
> 
> 
>  value="23">Auditing Home
>  value="17">Finance Home
>  value="122">Planning Home
>  value="231">Tax Home
> 
> 
> 
> 
> 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.

Tax Home


function mysubmit(var)
{
   document.theForm.parent.value = var;
   document.theForm.submit();
}


"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



Re: [PHP-DB] Pass database id through href

2004-04-13 Thread John W. Holmes
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)





Auditing Home
Finance Home
Planning Home
Tax Home


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.

Tax Home


function mysubmit(var)
{
  document.theForm.parent.value = var;
  document.theForm.submit();
}

"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


[PHP-DB] Pass database id through href

2004-04-13 Thread Gavin Amm
Hi.

I want to update mysql database with parent value of page.
I have several fields in my form.
I have a generated map of web site pages as hyperlinks at end of form.
(generated recursively)
I want to be able to click on hyperlink & have it pass the "parent"
value to the next PHP script.

The point of this is to select the "parent" page of the new/modified
page


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








Auditing Home
Finance Home
Planning Home
Tax Home




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??

Any help would be appreciated.

Regards,
Gav

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