0

I writing a method that check values in the current page along with one value from the previouse page. I use jQuery for writing the check as following

function check_Finalized() {
        myTest();
        var Finalized_value = document.createElement("INPUT");
        Finalized_value.type = "hidden";
        Finalized_value.name = "Finalized_value";

        if (((document.getElementById("ContentPlaceHolder1_txtFinalized") != null) && (document.getElementById("ContentPlaceHolder1_txtFinalized").value != "") && (document.getElementById("ContentPlaceHolder1_ddlResponsibility").value=="2") &&document.getElementById("ContentPlaceHolder1_chkSD").value =="checked"))

        {
            // document.getElementById("ContentPlaceHolder1_chkSD").value =="checked") && 
            if (confirm("Remember to forward finalisation email to Study Director" + "\n" + " You are shortly to receive the email in outlook")) {
                Finalized_value.value = "OK";
            } else {
                Finalized_value.value = "No";
            }
        }
       else
            Finalized_value.value = "OK";

        document.forms[0].appendChild(Finalized_value);
    }

Where (document.getElementById("ContentPlaceHolder1_chkSD").value =="checked")) is the value checked from the previous page.

5
  • when you say page, has the page been reloaded between pages or is the previous page just hidden when you move to the next page? If the former, then you cannot do this with jquery unless you ajax load in the next page whilst hiding the first page Commented Jul 4, 2017 at 15:25
  • The previouse page is just hidden when move into the next page. Commented Jul 4, 2017 at 15:27
  • I'm not sure I understood your question. You want to check a value from a previous page. Are they completely separated pages, or like baby steps forms? How are you storing the value of it? Commented Jul 4, 2017 at 15:27
  • Ok, I've just realised you haven't exactly said what you're problem is - is it that the if is not working? you may want to try adding some space between the && and the document. Also if you look at your console (f12 and hit the console tab in your browser), are there any error? Commented Jul 4, 2017 at 15:31
  • The problem is I get the following error :0x800a138f - JavaScript runtime error: Unable to get property 'value' of undefined or null reference, since the (document.getElementById("ContentPlaceHolder1_chkSD").value =="checked")) is not present in the current page. Commented Jul 4, 2017 at 15:36

1 Answer 1

2

Try,

document.querySelectorAll("[id$=chkSD]")

Sign up to request clarification or add additional context in comments.

4 Comments

I just relized that it is not getting any errors any more, however I still can't the right value. since the value I aquired is stored in the previous page/document. so document.querySelectorAll("[id$=chkSD]") looks into the current document, not the previous one :(
Are you accessing child page(content place holder value) in master page ? I think that is the case, just alert the output
The second page is a new page, so any method document.methods do not help. It must be something else that looks inside the application and fetch cashed data from the previous page.
The access data from different page, you can use query string or session variable in asp.net stackoverflow.com/questions/3734020/querystring-in-asp-net

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.