Very Dynamic Variable

Results 1 to 5 of 5

Thread: Very Dynamic Variable

  1. #1
    Patrik Guest

    Default Very Dynamic Variable

    OK !!! I&#039;ll give this a final try in the advanced section :)<BR><BR>I&#039;d like to output userdefined content and I&#039;d need a dynamically built var for that.<BR>My code:<BR>Set Temp3Content = connect.Execute(Get stuff from AccessDB)<BR>&#060;%= Temp3Content.Fields("FieldName").Value %&#062;<BR><BR>This worx but...<BR>What I&#039;d really need to do is to have the "Temp3Content"<BR>dynamic. In JS I would solve it kind of like this...<BR><BR>eval("Temp" & UserInp & "Content").Fields("FieldName").Value<BR><BR>Is this posible ???

  2. #2
    Shafe Guest

    Default Not advanced, just RTFM

    You answered your own question, all you need to do is RTFineM<BR><BR>Example (in VBScript):<BR><BR>&#060;%<BR> temp1 = "hello"<BR> temp2 = "there"<BR> intx = 1<BR><BR> response.write eval("temp" & intx)<BR>%&#062;

  3. #3
    Patrik Guest

    Default RE: Won't work though

    Hmm, yes I got the same reply earlyer in the forum.<BR>But I cant get it to work.<BR>Might this be an VB verion issue ???

  4. #4
    Justin Bonaparte Guest

    Default RE: Won't work though

    Patrik, I think you are confusing client and server side script. To get information back to the server, you would want to use a form element that is submitted. Once ASP has sent the code to the browser, the only way to send information back is through remote scripting (bleech!), form elements or cookies.

  5. #5
    Join Date
    Dec 1969

    Default EVAL only works in VBS version 5 and above...

    ...but you *should* be able to install version 5 on your machine, even if you don&#039;t install anything else more recent.<BR><BR>What kind of error do you get when you use EVAL?<BR><BR>One comment: It is best to EVAL the entire expression, not just the first part of it.<BR><BR>eval("Temp" & UserInp & "Content.Fields(""FieldName"").Value" )<BR><BR>I *do* have to ask why you need this. You are implying that you have multiple recordsets in use and are choosing one of them, yes? First of all, 90% of the time code that uses multiple recordsets is wrongly doing so. Almost always there is another (and better) solution using only a single recordset.<BR><BR>Second of all, there&#039;s a *truly* easy way to do this: Use an array.<BR><BR>&#060;%<BR>Dim allRSs( 4 ) &#039; or whatever number<BR>Set allRSs( 0 ) = RecordSetNumber0<BR>Set allRSs( 1 ) = RecordSetNumber1<BR>...<BR>Set allRSs( 2 ) = RecordSetNumber2<BR>%&#062;<BR><BR>And now no EVAL is needed:<BR><BR>allRSs( UserInp ).Fields("whatever").Value<BR><BR>does it for you.<BR><BR><BR> <BR>

Posting Permissions

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