Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3286202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:21:12+00:00 2026-05-17T20:21:12+00:00

Trying to pass a form value into a global var to be use in

  • 0

Trying to pass a form value into a global var to be use in two functions but get this error document.PostReply is undefined or the javascript just crashes because getReplyId is undefined within the functions. No matter what I have tried I get one or the other errors

Can anyone see why the form value “ReplyID” is not being passed into the var.
The var is placed at the begining of the script before any functions.

form

<CFFORM NAME="PostReply" ID="PostReply" METHOD="POST">   
<CFINPUT TYPE="hidden" NAME="ReplyID" ID="ReplyID" VALUE="#ReplyID#">  
</CFFORM>

what I have tryed

1 - var getReplyId = document.PostReply.ReplyID;  
2 - var getReplyId = document.PostReply.ReplyID.value;  
3 - var getReplyId = document.getElementById("ReplyID");  
4 - var getReplyId = document.PostReply.getElementById("ReplyID");    
5 - var getReplyId = document.getElementById("PostReply.ReplyID").value; `

If I just do this var getReplyId = 1 the script works great, but I need the ReplyID value.

Ok here is everything for the most part

<CFOUTPUT>  
<STYLE>  
targetPostReply#ReplyID#{visibility : visible}  
targetPostReplyResponse#ReplyID#{visibility : visible}  
</STYLE>  
</CFOUTPUT>

<cfajaxproxy cfc="CFC/PostReply" jsclassname="PostReplyCFC">

<SCRIPT SRC="js/PostReply.js" TYPE="text/javascript">
    var getReplyId = document.getElementById("ReplyID").value;   
    $(document).ready(  
        function () {  
        $("form#PostReply").submit(  
        function PostNewReply(ReplyID, ReplyComment){  
            var cfc = new PostReplyCFC();   
            cfc.setCallbackHandler(getNewReply)  
            cfc.setForm('PostReply')  
            cfc.PostNewReply('ReplyComment');  

            document.getElementById("targetPostReplyResponse"+getReplyId).style.display='block';  
            document.getElementById("targetMakeReply"+getReplyId);  
            $('#targetMakeReply'+getReplyId).slideToggle("slow");  
            $(this).toggleClass("targetMakeReply"+getReplyId);  
            return false;  
        }); // .submit()  
    });  
    function getNewReply(newReply)    
    {    
        $('#replyResponse'+getReplyId).html(newReply);  
        return false;  
    }   
</SCRIPT>


<CFOUTPUT>
    <DIV ID="targetMakeReply#ReplyID#">  
        <CFFORM NAME="PostReply" ID="PostReply" METHOD="POST">  
            <CFINPUT TYPE="hidden" NAME="ReplyID" ID="ReplyID" VALUE="#ReplyID#">  
            <textarea name="ReplyComment" rows="5" cols="95"></textarea>  
            <CFINPUT type="image" name="Submit" id="submitButton" value="Post Reply" src="images/PostReply.gif" onmouseover="src='images/PostReplyO.gif'" onmouseout="src='images/PostReply.gif'">  
        </CFFORM>  
    </DIV>  
</CFOUTPUT>


<CFOUTPUT>  
    <STYLE>##targetPostReplyResponse#ReplyID#{display : none}</STYLE>  
    <DIV ID="targetPostReplyResponse#ReplyID#">  
        <TABLE ALIGN="center" VALIGN="top" WIDTH="750" BGCOLOR="FFFFFF" CELLPADDING="0" CELLSPACING="0">  
            <TR>  
                <TD COLSPAN="2" CLASS="text12B"><IMG SRC="images/blank.gif" WIDTH="1" HEIGHT="5" ALT="" BORDER="0"><BR><SPAN ID="replyResponse#ReplyID#"></SPAN></TD>  
            </TR>  
        </TABLE>  
    </DIV>  
</CFOUTPUT>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:21:13+00:00Added an answer on May 17, 2026 at 8:21 pm

    Wrapped all the JS inside a new function call “SubmitReply” and passed the ID to it with an onclick “SubmitReply” in the INPUT Submit button. The ID (ReplyID) was then passed to a var getReplyId = (Id). This made the getReplyId use able by all the JS shown above. Now the JS, cfajaxproxy, and CFC can use the ID making the form dynamic with their own ID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use hidden fields in a form to pass along state selections
I am trying pass class as value in hashmap. I need to get the
im trying to pass two parameters to a function, i being an int value
I have am trying to pass the value of a label into the php.
I am trying to pass a form element into an MVC3 view by using
Im trying to pass a variable into the the google chart but when I
I'm trying to pass a form's data to my controller method using JQuery Ajax,
I'm trying to pass a variable from a child form that contains a DataGridView,
I have a web app with a form that I am trying to pass
So I am trying to use a button click to open the next form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.