Click to See Complete Forum and Search --> : Is this even possible?


kateyez44
10-22-2003, 08:44 AM
Hi, I am developing a web form that needs to contain a table with 20 rows, all exactly the same. What I'm doing to create this table is using a For loop to create the same controls 20 different times. This For loop is written in ASP/VBScript using Response.Write statements to create the HTML. When I create the only text box in each row, I have a need to call a JavaScript function in order to count the number of characters that have been entered into the text box so far and then display how many characters are remaining in a label below the text box. This is where the problem lies.

One of the parameters of the JavaScript function that I have to call is a string. I cannot figure out how to pass the string in with the correct syntax since the Response.Write statement is already enclosed in double quotes (" ") and the JavaScript event is already enclosed in single quotes (' '). Because of this, I cannot enclose the string parameter in any sort of quotes because it causes a syntax error. Here is what my code looks like, with the problem being in red:


Response.Write "<INPUT TYPE=TEXT NAME='txtReasonOther" & i & "' SIZE=35 TITLE='wStatus(this);' ONFOCUS='wStatus(this);select(this);'"

Response.Write " ONMOUSEOVER='wStatus(this);' ID='Question 15.Reason" & i & ".Other' TABINDEX=" & tabIndx

Response.Write " ONKEYPRESS='countChars(this,'15.Reason" & i & ".Counter',78);' ONKEYDOWN='countChars(this,'15.Reason" & i & ".Counter',78);'"

Response.Write " ALT='wStatus(this);' VALUE='" & strReasonOther & "'><BR>"

Response.Write "<SPAN CLASS='Normal'><LABEL NAME='lblCounter" & ctrIndx & "' ID='15.Reason" & i & ".Counter' FOR='Question 15.Reason" & i & "' CLASS='" & ctrClass & "'>78</LABEL> characters left</SPAN>"

Response.Write "</TD>"


I understand why the highlighted variables should not be enclosed in single quotes, but how can I go about passing this variable in? Is it even possible to do this when using the Response.Write to call JavaScript functions from an event? Any help is greatly appreciated.

Thanks,
Crystal

kateyez44
10-22-2003, 09:01 AM
Okay, after 3 days of fiddling with this, I finally figured it out after giving up and posting this question. Sorry to take up your time.