Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default to a radio button onclick or onload

    Hello I can't figure out how to code this. Right now I have 3 radio buttons edit/print/search. I need it to go back to the edit radio button either onclick or onload. Don't know what would be better. My codding looks like this so far:

    <input type="radio" name="radiooption" value="Edit"<cfif #Session.radiooption# IS "Edit">CHECKED</cfif> onClick="this.form.submit();">Print<input type="radio" name="radiooption" value="Print"<cfif #Session.radiooption# IS "Print">CHECKED</cfif> onClick="this.form.submit();">search<input type="radio" name="radiooptione" value="search"<cfif #Session.radiooption# IS "search">CHECKED</cfif> onClick="this.form.submit();"></font>

    <input type="button" name="ClearLabels" value="Clear Labels" style="font-size: 9px;" onClick="this.form.submit();">

    What I need done in the end is when Clear Labels is clicked. I need it to clear the label que (which it does that now), but I need it to also go back to the edit radio (#Session.radiooption# IS "Edit") radio button. What would the best way to do this be?

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,330
    Thanks
    23
    Thanked 616 Times in 615 Posts
    I don't know what <cfif> is so I have left them out of answer.
    2. I put things in lower case because that's how their should be.
    3. I am guessing, because you are submitting form for every action, that your page is being re-displayed all the time. So the answer is in the way the radio buttons are displayed:
    Code:
    Edit  <input type="radio" name="radiooption" value="Edit" checked="true" onclick="this.form.submit();">
    <br />
    Print <input type="radio" name="radiooption" value="Print" onclick="this.form.submit();">
    <br />
    Search<input type="radio" name="radiooption" value="search" onclick="this.form.submit();">

  • #3
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    @sunfighter: If you don't know what <cfif> is, then you probably shouldn't answer questions in the ColdFusion forum However, good job on cleaning up that code...

    @taunnt: What does your ColdFusion code look like that clears your label queue? Can you possibly just re-set session.radioOption back to "edit" when you clear your queue? (i.e. <cfset session.radioOption = "edit">)

    Your HTML code should probably look like this in general though:
    Code:
    Edit <input type="radio" name="radioOption" value="Edit" onclick="this.form.submit();" <cfif session.radioOption eq "edit">checked="true"</cfif>><br />
    
    Print <input type="radio" name="radioOption" value="Print" onclick="this.form.submit();" <cfif session.radioOption eq "print">checked="true"</cfif>><br />
    
    Search <input type="radio" name="radioOption" value="search" onclick="this.form.submit();" <cfif session.radioOption eq "search">checked="true"</cfif>><br />
    
    <input type="button" name="ClearLabels" value="Clear Labels" style="font-size: 9px;" onClick="this.form.submit();">
    -Greg

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,330
    Thanks
    23
    Thanked 616 Times in 615 Posts
    Sorry. Didn't realize I was in Cold Fusion section

  • #5
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    Haha, all good man


  •  

    Posting Permissions

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