How to display other information after clicking a button?

My intention: first I want to display a button on the page, after clicking the button, the button will be removed and other information is displayed. So I used the following code, but it doesn't work, the button still exists and the "other information" is also not displayed. Can you guys give any suggestions where I was wrong? Thanks in advance.

This is the code to display information:

    <cfif displayMessage eq 1>
        <cfif ifUploaded eq 0>
            <div id='message_box'>
            <cffile action="upload" filefield="PRESENTATION_FILENAME" destination="#ExpandPath("./uploads/")#" nameconflict="overwrite">
            <cfset myfile = #cffile.clientFile#>
            <cfset myurl = mid(cgi.HTTP_REFERER,1,46) & 'uploads/' & #myfile#>
            <div id="btn"><input type="button" name="kalturaBtn" value="upload to kaltura" href="javascript:void();" onclick="popupwindow('https://lampa.human.cornell.edu/csg.kaltura/test.php?kurl=#myurl#&kname=#form.title#&rec=#ddl_choice#','','1200', '700'); return false;"></div>
           </div>
        </cfif>
     </cfif>

    <cfif ifUploaded eq 1>
        <div id='message_box'>
        <div>#messageTitle#</div>
        <div>#messageBody#</div>
    </cfif>

      

and I have the following code to set "displayMessage" and "ifUploaded" to display different information after clicking "kalturaBtn".

<cfif kalturaBtn eq "upload to kaltura"> 
    <cfset ifUploaded = "1">
    <cfset displayMessage = "0">
</cfif>

      

The reason I used a different "displayMessage" variable is here: all this information will only be displayed after the form is submitted on this page.

HTML code:

     <cfoutput>
        <cfform name="frmPresentation" id="frmPresentation" action="#CGI.SCRIPT_NAME#" enctype="multipart/form-data">

        <!--- Information Table --->
        <div id='main_body'>
            <div id='inside'>
            <div style='text-align: center; font: bold 18pt Arial, Helvetica, sans-'serif'>CHE Multimedia Management Page</div>
                <br/>
                <cfif displayMessage eq 1 AND len(form.PRESENTATION_FILENAME) gt 0>
                    <cfif ifUploaded eq 0>
                    <div id='message_box'>
                        <cffile action="upload" filefield="PRESENTATION_FILENAME" destination="#ExpandPath("./uploads/")#" nameconflict="overwrite">
                        <cfset myfile = #cffile.clientFile#>
                        <cfset myurl = mid(cgi.HTTP_REFERER,1,46) & 'uploads/' & #myfile#>
                        <div id="btn"><input type="button" name="kalturaBtn" value="upload to kaltura" href="javascript:void();" onclick="popupwindow('https://lampa.human.cornell.edu/csg.kaltura/test.php?kurl=#myurl#&kname=#form.title#&rec=#ddl_choice#','','1200', '700'); return false;"></div>
                        <span onclick='this.parentNode.style.display="none"'></span>
                       </div>
                    </cfif>
                 </cfif>

                    <cfif ifUploaded eq 1>
                        <div id='message_box'>
                        <div>#messageTitle#</div>
                        <div>#messageBody#</div>
                        </div>
                    </cfif>

                   <cfdump var="#kalturaBtn#">

     // a lot of other code omitted here
     <input type='submit' name='submitMedia' value='Submit Changes' class='submit' onclick='return confirmSubmit()'/>
    </form>
    </cfoutput>

      

+3


source to share


1 answer


Ok, maybe this will help you.

You are trying to use a regular button to submit a form.

<input type="button" name="kalturaBtn" value="upload to kaltura" href="javascript:void();" onclick="popupwindow('https://lampa.human.cornell.edu/csg.kaltura/test.php?kurl=#myurl#&kname=#form.title#&rec=#ddl_choice#','','1200', '700'); return false;">`

      



Instead, you need to use the submit button. Another reason causing the problem for you is that after the popupwindow()

script you have return false

that cancels the form submission. Change both of these things like this and your form should work. Also, input elements do not have href attributes.

<input type="submit" name="kalturaBtn" value="upload to kaltura" onclick="popupwindow('https://lampa.human.cornell.edu/csg.kaltura/test.php?kurl=#myurl#&kname=#form.title#&rec=#ddl_choice#','','1200', '700')">`

      

Your page didn't change because your form wasn't submitting.

+1


source







All Articles