include file

Results 1 to 2 of 2

Thread: include file

  1. #1
    Join Date
    Dec 1969

    Default include file

    in an included javascript file, I have two functions...<BR><BR>function test_1()<BR>{<BR> alert("test1");<BR>}<BR><BR>function test_2()<BR>{<BR> alert("test2");<BR>}<BR><BR>From the asp page, I include this js file and attempt to call the functions but I need to call them based on a variable...<BR><BR>var conf_num;<BR>conf_num = 2;<BR><BR>instead of calling<BR> test_2();<BR>I need to do something like<BR> test_ & conf_num & ();<BR><BR>Is that possible?<BR><BR><BR>Another questions is, can I include the js file based on a variable...<BR>instead of <BR> &#060;script language=javascript src="test2.js"&#062;&#060;/script&#062;<BR>can I do something like<BR> &#060;script language=javascript src="test & conf_num & .js"&#062;&#060;/script&#062;<BR><BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default You can...

    ...use eval() for your first problem:<BR><BR>eval("test_" + conf_num + "()");<BR><BR>The second problem is a little bit trickier. I think you could do it if you were using ASP. But I&#039;m not too sure about this one.<BR><BR>Oliver.

Posting Permissions

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