Forum Moderators: open

Message Too Old, No Replies

URGENT Help with TEXT vs. Number.

can't get "imported" variable to work with TEXT

         

jcsjcs

8:27 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



All - I am using a web-based survey solution to get some info from my clients. The survey tool enables the passing of "responses" to javascript. The code below is an example of a problem I am having that I can't seem to solve.

The code below takes the input from question 1 in the survey and writes it back out to the browser. The syntax in the survey tool is ${question_1} for question 1, ${question_2} for question 2, etc.

The problem is that if the response to question 1 is a NUMBER, the script below works fine. BUT if the response is TEXT, the javascript does not work. I am guessing the problem is due to the fact that I don't have quotes around the survey tool variable - but I can't because then the variable will not get set properly.

Any suggestions on how to solve this?

<script type="text/javascript">
document.write(${question_1});
</script>

So if Question 1 = 123123 then
123123 is written to my browser.

BUT if Question 1 = HELLOWORLD then
the Javascript does not work!

HELP!

d40sithui

8:41 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



try taking off the $ {} in your code? why do you need this part?
i tried your script, but it does not seem to work either way(they both come up empty).


<script type="text/javascript">

var question_1 = 12345;
var question_2 = "hello world";

document.write(question_1);
document.write(question_2);
</script>

jcsjcs

8:49 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



The $ is a requirement of the Survey Tool. I tried to remove the $ by using {question_1} instead of ${question_1} and now both TEXT and NUMBERS don't work. They don't blow up - BUT I don't get a value from the Survey Tool.

The problem seems to be how the VAR portion of the script is working. When I am declaring a NUMBER from the survey tool it is fine, but when I am declaring a STRING, it blows up.