Forum Moderators: open

Message Too Old, No Replies

Submit form using text and making it a value also.

         

norek

11:02 pm on Oct 2, 2005 (gmt 0)

10+ Year Member



I have a form that submits to a PHP file to search the site... I can type the words into a text field then perform the search no problem...

I need a menu like this showing on the front page:

- Brakes
- Car customising
- Decals & Aesthetics

I tried making the text act as a submitter, and it worked, this is what I did:

<a href="javascript:document.FormName.submit();">Brakes</a>

Now, I need to be able to assign a NAME and a VALUE to this text so that by clicking it, it will automatically submit the form and feed it the search keyword at the same time.

garann

4:44 pm on Oct 3, 2005 (gmt 0)

10+ Year Member



There are several ways you can do that. The two easiest would be to pass the name and value in the querystring:

<a href="javascript:document.FormName.action+='?search=Brakes';document.FormName.submit();">Brakes</a>

Or, a little neater, to use a hidden field to store your value:

<a href="javascript:document.getElementById('search').value='Brakes';document.FormName.submit();">Brakes</a>
<input type="hidden" name="search" id="search">