 |

jghoward2007
User
Dec 10, 2007, 5:51 AM
Post #1 of 3
(4634 views)
Shortcut
|
|
Javascript Form Conditional Templates
|
Can't Post
|
|
Is there a way using javascript (or otherwise) one could have a form such that a different template is called depending on some of the variables used? Just for example, if a person selects 'town1' from a dropdown menu, the form calls search.cgi&template=_search_results1 and if the person selects 'town2', the form calls search.cgi&template=_search_results2.
|
|
|  |
 |

Dave
Staff
/ Moderator

Dec 10, 2007, 9:05 AM
Post #2 of 3
(4621 views)
Shortcut
|
|
Re: [jghoward2007] Javascript Form Conditional Templates
[In reply to]
|
Can't Post
|
|
Yes, the could work. It's well outside what we usually recommend or support, but if you're comfortable with javascript and wanted to give it a try the code might look something like this: - Give the town dropdown an id: name="town" id="town" - Give the hidden template field an id: name="template" id="template" - add an onchange event to the town dropdown: <select name="town" id="town" onchange="document.getElementById('template').value = this.value + '.html'"> That will set the template field to the name of the town with .html on the end. eg: vancouver.html If it was much more complicated than that you'd probably want to put that code in a function. Hope that helps! :) Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

jghoward2007
User
Dec 10, 2007, 10:57 AM
Post #3 of 3
(4618 views)
Shortcut
|
|
Re: [Dave] Javascript Form Conditional Templates
[In reply to]
|
Can't Post
|
|
Thank You So Much! The "town dropdown" name and id are set to lfield2_match; It seems to work and may be exactly the solution I needed. If there are any caveats you can think of, please let me know. Cheers! John
|
|
|  |
|