...

View Full Version : Display .innerhtml variable contents using <%response.write()%>



mark1p
02-26-2006, 07:04 PM
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

degsy
02-27-2006, 02:57 PM
You are mixing ASP and Javascript.
Post an example of your code or an example page.

Why are you using innerHTML?

mark1p
02-27-2006, 07:20 PM
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>

Brandoe85
02-27-2006, 08:56 PM
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?


<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):


<%

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;

mark1p
02-28-2006, 11:12 AM
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.
:thumbsup: Thanks again for your time and effort.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum