• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Trying to mix JavaScript and coldfusion unsuccesfully

i am trying to create a simple form where people choose their templates. this is within a larger page as a cfdiv element. on click, i want to navigate over to the template.

I need to get the "[document.getElementById('TemplateType').value]" or something like that too actually work.

thank you in advance.
this works if i hardcode a file template name (areatemplate1, areatemplate2, etc)


<cfform name="TemplateChange">
 
    <cfoutput>
 
       
        <cfinput name="AID" value="#AID#" type="hidden">
         
            <select name="TemplateType">
                  <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
            </select>
               
       
       
            <br />
            <cfinput type="submit" id="saveID" value="save" name="save" onClick="ColdFusion.navigate('/cms/arealist/areatemplates/areatemplates/areatemplate[document.getElementById('TemplateType').value]', 'templateDiv');"  >
            <cfinput type="submit" id="close" value="close" name="close">
     </cfoutput>
</cfform>
0
ojohnson
Asked:
ojohnson
1 Solution
 
azadisaryevCommented:
you concatenate strings and js variables like this:
'string' + jsvariable

so your onclick event should look like this:
onclick="ColdFusion.navigate('/cms/arealist/areatemplates/areatemplates/areatemplate' + document.getElementById('TemplateType').value, 'templateDiv');"

i am also not sure i would put it as onclick event in a submit button - unless you really want to also submit the form when the button is clicked. otherwise, either use cfinput type="button" or add return false; to the end of onclick event to prevent form submission:
onclick="ColdFusion.navigate('/cms/arealist/areatemplates/areatemplates/areatemplate' + document.getElementById('TemplateType').value, 'templateDiv'); return false;"

Azadi
0
 
ojohnsonAuthor Commented:
Ok thank you. I do need to the form to submit as well. Thank you for your quick response
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now