Refer to a button in a form by ID rather than name

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default Refer to a button in a form by ID rather than name

    Hi,

    I would like to know if there is a way to call or refer to the radio button
    with it's id tag not the name because when I have the two different names for
    my radio buttons I am facing a problem.

    The problem is that when you select one of my two radio buttons and submitt
    the form, that button stays checked, even if you select the other button.



    ----------------------html form------------------
    <form id="quicksearch" name="quicksearch" action="scripts/search.cfm"
    method="post">

    <label for="quicksearchBox">Search:</label> <input class="styledinput"
    tabindex="1" accesskey="S" type="text" name="Search" id="quicksearchBox"
    size="9" /><input class="styledinput" tabindex="2" type="submit" value="Go"
    id="quicksearchButton" /><br /><br />

    <p><input type="radio" accesskey="J" name="type" id="Jmsb" value="J"/> JMSB
    </p>

    <p><input type="radio" accesskey="C" name="type" id="Conc" value="C" /> DIS
    </p>
    ----------------------------------------------------------
    cfm file

    <CFSET myVAR1 = "http://www.google.com/u/concordiau?q=/#FORM.Search#">
    <CFSET myVAR2 = "http://www.google.com/u/jmsb?q=/#FORM.Search#">

    <cfif isdefined("FORM.Jmsb")>
    <cflocation url= "#myVAR2#" addtoken="no">
    </cfif>

    <cfif isdefined("FORM.Conc")>
    <cflocation url= "#myVAR1#" addtoken="no">
    </cfif>

    JMSB Guest

  2. Similar Questions and Discussions

    1. Form button help
      Hello, I'm working in MX2004. I've made a Form so that someone can fill out their info and submit it to a mailing list. The layout and presentation...
    2. slave buttons that refer to master button actions
      Hi Just as the message title says, I'm looking to have 50 buttons refer to a get URL action contained in a master button (which is in the same...
    3. Problem with Button using Form.pm
      Hi, I have a page with a Input Type Button : <INPUT TYPE="button" NAME="_wiznext" VALUE=" Next " ONCLICK="openURL(this.form);"> But I am...
    4. Form Search Button
      Hi I have almost finished a database and it does everything I want it to at the moment except one thing. On the Forms that I have made, I have...
    5. JavaScript Access to Button in form tags (webcontrol or html button)
      Hello, I have a button called LoadBtn, which exists in <form name="Form1" runat=server></form> tags. I then have javascript loaded outside of...
  3. #2

    Default Re: Refer to a button in a form by ID rather than name

    Why don't you give them the same name and different values? That way, they
    would act like radio buttons.

    Originally posted by: JMSB
    Hi,

    I would like to know if there is a way to call or refer to the radio button
    with it's id tag not the name because when I have the two different names for
    my radio buttons I am facing a problem.

    The problem is that when you select one of my two radio buttons and submitt
    the form, that button stays checked, even if you select the other button.





    Dan Bracuk Guest

  4. #3

    Default Re: Refer to a button in a form by ID rather than name

    Hi JMSB

    In my opinion, this is sufficient -- without id attribute, and without end-tag,
    unless you're using xhtml, etc.

    p><input type="radio" accesskey="J" name="type" value="J"> JMSB </p>
    <p><input type="radio" accesskey="C" name="type" value="C"> DIS </p>



    BKBK Guest

  5. #4

    Default Re: Refer to a button in a form by ID rather than name

    When you're using a group of radio buttons and want to restrict that only one
    be chosen, they all have to have the same name. In order to process the
    selected radio button, you should setup a default value for the element in case
    none are chosen, then you'll have to check each possible value if you doing
    something different per possible value.


    <!--- formPage.cfm --->
    <form name="someForm" action="actionPage.cfm">
    <p><input type="radio" name="type" value="J" /> J</p>
    <p><input type="radio" name="type" value="C" /> C</p>
    </form>

    <!--- actionPage.cfm --->
    <cfparam name="form.type" type="string" default="" />

    <cfif form.type IS "J">
    <cflocation url= "#myVAR2#" addtoken="no">
    </cfif>

    <cfif form.type IS "C">
    <cflocation url= "#myVAR1#" addtoken="no">
    </cfif>

    <!--- OR --->

    <cfparam name="form.type" type="string" default="" />

    <cfswitch expression="#form.type#">
    <cfcase value="J">
    <cflocation url= "#myVAR2#" addtoken="no">
    </cfcase>
    <cfcase value="C">
    <cflocation url= "#myVAR1#" addtoken="no">
    </cfcase>
    <cfdefaultcase>
    <cflocation url= "formPage.cfm?err=1" addtoken="no">
    </cfdefaultcase>
    </cfswitch>

    cf_menace Guest

  6. #5

    Default Re: Refer to a button in a form by ID rather than name

    Thx alot cf_menace........you rock :)...It worked
    JMSB Guest

  7. #6

    Default Re: Refer to a button in a form by ID rather than name

    Thx alot cf_menace........you rock :)...It worked
    JMSB 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