Javascript variables

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Javascript variables

    How can I pass a javascript variable to coldfusion before submitting a form ?
    Basically, I need to know the value of a drop down box selection, and based on
    that value, when the user clicks submit, I launch a one of 2 possible pages.

    Mario Giannone Guest

  2. Similar Questions and Discussions

    1. How to pass variables from JavaScript to Flex
      Dear Flex comunity, Is there anyone who knows why isn't this code working? --FLEX 3-- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"...
    2. Javascript variables to cold fusion
      I created variables in javascript and would like to have them available to me in cold fusion code. Does anyone know how I can do this? In the...
    3. Setting Global Variables from Javascript
      Okay, here's the situation. I'm using an FSCommand to trigger a function in the javascript page that is hosting a flash movie I'm working on. Within...
    4. Setting variables in director from javascript
      Due to the complexity of a project, I have decided to use Director over javascript. I'm apt in programming, but cannot seem to find a simple answer....
    5. Passing variables from ASP to Javascript
      I am using ASP to open a text file on the server and I want to pass variables to Javascript. Any suggestions? For example - I have a text file...
  3. #2

    Default Re: Javascript variables

    One way would be to have the action page examine the option selected and call
    the appropriate page, all CF. You can change the action page with JS with
    document.FormName.action = vProgram;. You just have to condition that on the
    option selected vOption =
    document.FormName.DropDowns.options[document.FormName.DropDown.selectedIndex].va
    lue;

    CFGumby Guest

  4. #3

    Default Re: Javascript variables

    I'm not sure I know what you mean ? what if I make the values of the select
    options the actual names of the pages I want to launch: How do I return that
    value to the action attribute ? <form name='form1' method='post'
    action='?????' target='_blank'> <select name='cmbRequestType'> <option
    value='Page1.cfm'>Selection One</option> <option
    value='Page2.cfm'>Selection Two</option> </select>

    Mario Giannone Guest

  5. #4

    Default Re: Javascript variables

    Sorry, I wasn't that clear. Bur your example:

    <form name="form1" method="post" action="?????" target="_blank"
    onsubmit="changeaction();">
    <select name="cmbRequestType">
    <option value="Page1.cfm">Selection One</option>
    <option value="Page2.cfm">Selection Two</option>
    </select>

    Then you would have the matching function
    <script>
    function changeaction() {
    vSelectedPgm =
    document.form1.cmbRequestType.options[document.form1.cmbRequestType.selectedInde
    x].value;
    document.form1.action = vSelectedPgm ;
    {
    </script>



    CFGumby Guest

  6. #5

    Default Re: Javascript variables

    that worked great !
    Thank you very much for your help !
    Mario Giannone Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139