Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pull from a .js doc

Status
Not open for further replies.

TickleMeEmo

Programmer
Feb 20, 2003
9
0
0
US
I'm new to ASp, so please bear with me.

I want to pull an array from a .js doc.
I'm passing the variable in the url string, lets call it "id".

So my url looks like this

Using ASP, i would like to call a file called quote.js and pull that id from it.

the first couple lines of my .js file look like
var quotes = new Array();
quotes[0]='quote lives here'
quotes[2]='quote lives here'
and so on

I've always done this in javascript, but I need to use ASP so I can pass the vaiable along in an email.
 
this will print out the following elment in your array.

document.write(quotes[<%=request.querystring(&quot;id&quot;)%>]) ________________________________________________________________________
Are you trying to debug your ASP applications? See faq333-3255 for more details

regards,
Brian
 
whoa... i don't think that makes any sense. If the array is already loaded in the page via a <script> element, why make a trip back to the server just to fill in the array index in the client script?

-pete
 
Unless I'm not clear on what is being asked, it looks as if id is being passed from another page. Since the array is already built with static content (I'm assuming), then to get an element out of the array on the target page, the method I described above would do it.

Am I missing something Pete? ________________________________________________________________________
Are you trying to debug your ASP applications? See faq333-3255 for more details

regards,
Brian
 
DOH! No i did!

>> it looks as if id is being passed from another page.

[hammer]
Now i get it

Thanks Brian
-pete

 
hmm.. I could be wrong also but I think what is wanted is backwards from that.

TickleMeEmo
if I'm reading it right and you want to parse the .js to extract the values with a hard coded array then this should be done on a submission in the page by passing the values form the .js populated into hidden form fields and thus being able to request them. Is seems kind of long winded to go through a FSO and parse out the values in there to get them when you can do a few lines of coding to do it the way I suggest.

or I could be reading it wrong too. [wink] onpnt
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
onpnt2.gif
[sup] [/sup]
 
I need the element back in a ASP variable.

Yes, the variable is coming from another page.

I want to use ASP to go to the .js doc, grab the element that matchs the id and return it in a ASP variable so I can stick it in my ASP email script.



 
palbano said
--> DOH! No i did!

onpnt said
onpnt, DOH! you idiot, wait to see if you're wrong to before you shoot your fingers off.

[lol] onpnt
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
onpnt2.gif
[sup] [/sup]
 
[cannon] [bugeyed]

just tell me to shutup whenever you want, until then.

>> so I can stick it in my ASP email script.

I would copy the .js array into a .asp file so i could just access the element directly. Unless there is some problem with how the file get built or something.

-pete
 
[cannon] . . . ( Pete ) ________________________________________________________________________
Are you trying to debug your ASP applications? See faq333-3255 for more details

regards,
Brian
 
I agree with Pete on his last posting. The array will be easier to manage and manipulate with ASP should you go that route. ________________________________________________________________________
Are you trying to debug your ASP applications? See faq333-3255 for more details

regards,
Brian
 
Ok, I copied my .js to my asp page.


looks like this
<%
Dim AspVariable(99)
quotes[0]='quote lives here'
quotes[1]='quote lives here'
and so on

Now I want the id from the url
<%=request.querystring(&quot;id&quot;)%>

How do I get the element from the array that matchs my id?
I want that element to be a ASP variable.
then I'll include that variable in the body of my Email and be done.

(scratching head...)


 
EmailObj.setBody( quotes[ Request(&quot;ID&quot;)])

don't know your email object interface but you should get the idea.

Also in VBScript you might have to convert Request(&quot;ID&quot;) into a Number type first. Hopefully some VB people will step in here.

-pete
 
remember that vbscript takes () around the array element also not []
onpnt
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
onpnt2.gif
[sup] [/sup]
 
that does look pretty funny doesn't it
()()()()()()()() onpnt
_________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
onpnt2.gif
[sup] [/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top