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
    Feb 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display .innerhtml variable contents using <%response.write()%>

    I'm trying to get some display on screen for user test results from a previously written script that posts test results to a database. I would like to show the results, etc. using a <%response.write() %> but can't seem to get the syntax correct to get the content of any of these .innerhtml variable contents to be shown.

    The following coding snippet contains some of the variable content I need to display to the user but I have read lots of stuff on the web but it all seems a be too in depth for my level of experience which is just over the zero level!

    Any help would be much appreciated as I have seen more error messages on screen for the various attempts i've made over the last couple of days.

    SimScoreSentance.style.display='block';
    SimErrors.innerHTML = Errors+' ';
    SimTotal.innerHTML = DisplayScreen.TotalSteps;
    SimScore.innerHTML = USERSCORE + "%";
    SimArea.style.display='none';
    SimCompleted.style.display='block';


    Cheers
    Mark

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are mixing ASP and Javascript.
    Post an example of your code or an example page.

    Why are you using innerHTML?

  • #3
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What I know of asp is very little, what I know of javascript is even less!

    the bit of code that is causing me problems and mistifying me is shown below. What happens on this screen is it shows the result of a simulation showing the test results saying I have got x number of errors out of y and gives me a percent score.
    I'm attempting to be able to post this info. to a database but somehow as if by magic the contents are somehow hidden in between the <div> </div> tags. I would like to extract this info. place it in a hidden field on a form and then post the results to a processing asp file on the click of a submit button. Because the variable content is somehow buried from view I assumed that if I could somehow grab the variable contents and then do something with it.
    pls help and direct me to a possible solution to my problem.

    <!-- ****Completed**** -->
    <div name="SimCompleted" id="SimCompleted" style="display:none; margin-top: 5%; margin-left: 20px ">
    You have completed the task.
    <br />
    <br />
    <div name="SimScoreSentance" id="SimScoreSentance" style="display:none">
    You made <div name="SimErrors" id ="SimErrors" style="display:inline"></div> errors out of <div name="SimTotal" id="SimTotal" style="display:inline"></div>, resulting in a score of <div name="SimScore" id="SimScore" style="display:inline"></div>.
    </div>
    <a href="#" onClick="Reset()">Start over</a>
    </div>

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    So you want a form on your page with a submit button, that will send those values from the divs to hidden form fields for you to process on the next page?
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function Move(oForm)
    {
    	// divs
    	var score = document.getElementById('SimScore');
    	var err = document.getElementById('SimErrors');
    	var total = document.getElementById('SimTotal');
    
    	// hidden fields
    	oForm.score.value = score.innerHTML;
    	oForm.err.value = err.innerHTML;
    	oForm.total.value = total.innerHTML;
    }
    </script>
    </head>
    <body>
    <!-- ****Completed**** -->
    <div name="SimCompleted" id="SimCompleted" style="display:none; margin-top: 5%; margin-left: 20px ">
    You have completed the task.
    <br />
    <br />
    <div name="SimScoreSentance" id="SimScoreSentance" style="display:none">
    You made <div name="SimErrors" id ="SimErrors" style="display:inline">error</div> errors out of <div name="SimTotal" id="SimTotal" style="display:inline">total</div>, resulting in a score of <div name="SimScore" id="SimScore" style="display:inline">score</div>.
    </div>
    <a href="#" onClick="Reset()">Start over</a>
    </div>
    <form onsubmit="Move(this);" action="yourpage.asp" method="post">
    <input type="hidden" name="score">
    <input type="hidden" name="err">
    <input type="hidden" name="total">
    <input type="submit">
    </form>
    </body>
    </html>
    Then in the processing page(form action page, thats in red):
    Code:
    <%
    
    Response.Write(Request.Form("score") & "<br>" & Request.Form("err") & "<br>" & Request.Form("total"))
    
    %>
    Let me know if i'm not following you correctly.

    Good luck;

  • #5
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent stuff...works like a dream!
    I wouldn't have got very far without your assistance as the javascript bit was a bit out of my league at the moment.
    Thanks again for your time and effort.


  •  

    Posting Permissions

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