|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Change form action
I have a search-form with this code:
PHP Code:
What I wan't is to change the form-action to the chosen value of the option-menu, but I don't know how to do this. Any idea? |
|
#2
|
||||
|
||||
|
It probably makes more sense to have your select box contain values that you test against server side, performing the appropriate search depending on which option was selected. There's probably a way to change the form action, but relying on javascript to do this clumsily seems to me like a bad option. You have more control server-side.
|
|
#3
|
|||
|
|||
|
are you using PHP, ASP, CGI? either way you should be able to set that as a variable that ties to a drop menu . that might work, i think.
__________________
Dave www.fs3d.com |
|
#4
|
||||
|
||||
|
To alter the form using JS, use the event handler called onChange in your select box
Code:
<selet name="drpHref" onChange="jumpTo()"> <option>...</option> </select> The bit that actually changes the forms action is simply: Code:
document.frmName.action = newValueHere |
|
#5
|
|||
|
|||
|
Thank's for responding everybody. I'm using ASP.
Right now I'm using a Dreamweaver MX Javascript, it kind of work's, but it's not perfect (I think). If someone have a example I will be glad. |
|
#6
|
||||
|
||||
|
Here's one way of doing it. The example here is not very re-usable, though it gives you a general idea of how it works. Also, they use a button to trigger the link, rather than using the onChange handler (which I prefer - but means a user must have JS enabled).
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Change form action |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|