Skip to main content
Known Participant
May 21, 2013
Question

show and hide with radio button

  • May 21, 2013
  • 1 reply
  • 592 views

Hi,

when i click on the radio button, the text box for fname is showed.  If i don't enter anything into text box then hit submit, the pop up will display with code for validate below.  When i hit OK to go back,

the text box is gone but the radio button still checked.  How can i keep the text box stays on the page?

<!---form.cfm--->

<cfform name="myform" action="action.cfm">

<cfinput type="radio" name="approve" value="1" onclick="show('d0','d1')" />

<div id="d0">

<cfinput type="text" name="fname">

</div>

<cfinput type="submit" name="submit" value="Add">

</cfform>

<!---action.cfm--->

<cfif isDefined("form.submit")> 

    <cfif Not Len(Trim(form.fname))>

        <script type="text/javascript">

        alert("Name can not be blank.");

        history.back(-1);

        </script>

         <cfabort>

    </cfif>

</cfif>

Thanks

KT

    This topic has been closed for replies.

    1 reply

    WolfShade
    Legend
    May 21, 2013

    Write JavaScript that will check the status of the radio button upon form.cfm load, then show/hide accordingly.

    ^_^

    newcfAuthor
    Known Participant
    May 21, 2013

    i am not good at this, can you please provide any example?