POPULATE AN ARRAY
-
Got a asp page. (DB search page) in one frame. BASIC db with a single search on one field and passed back to same page. (So page refreshes with new search result) NOW I need to just build an array that STAYS and gets added to even if you do another and another and another search (Just to track what elements in DB was selected in each search page) and then display the array in a second frame on the page after each selection was made? IS THIS EASY ENOUGH??? Any help would be appreciated. New to this line of coding. :) this is me
-
Got a asp page. (DB search page) in one frame. BASIC db with a single search on one field and passed back to same page. (So page refreshes with new search result) NOW I need to just build an array that STAYS and gets added to even if you do another and another and another search (Just to track what elements in DB was selected in each search page) and then display the array in a second frame on the page after each selection was made? IS THIS EASY ENOUGH??? Any help would be appreciated. New to this line of coding. :) this is me
You can use javascript to send a string or array to the other frame, and in a function in that frame handle the collection of items. Example: Script to send a string of id:s to the other frame:
top.otherFrame.addItems('4,7,18,42');
Script in the other frame that adds the id:s to a string:var items = ''; function addItems(id) { items += (items.length?',':'') + id; }
This is just a method for sending the data. If you want to display anything in the other frame, you have to add code for that. Perhaps you need to reload that page in order to get more information about the items than just the id. --- b { font-weight: normal; } -
You can use javascript to send a string or array to the other frame, and in a function in that frame handle the collection of items. Example: Script to send a string of id:s to the other frame:
top.otherFrame.addItems('4,7,18,42');
Script in the other frame that adds the id:s to a string:var items = ''; function addItems(id) { items += (items.length?',':'') + id; }
This is just a method for sending the data. If you want to display anything in the other frame, you have to add code for that. Perhaps you need to reload that page in order to get more information about the items than just the id. --- b { font-weight: normal; }Thanks for the quick responce again. Will try this tonight. Can I then just do a page refresh IN that script code (I am just using VB at the moment all though almost all my previous coding experience is in c++ (Java etc)) function addItems(id) { items += (items.length?',':'') + id; (PAGE REFRESH THINGY :) } What would be the page refresh code then? I assume there is simply a sinlg line of code to do this? THUS when something gets passed to this page as in the first part, then this will update the array and then refresh the page??? I HOPE? this is me
-
Thanks for the quick responce again. Will try this tonight. Can I then just do a page refresh IN that script code (I am just using VB at the moment all though almost all my previous coding experience is in c++ (Java etc)) function addItems(id) { items += (items.length?',':'') + id; (PAGE REFRESH THINGY :) } What would be the page refresh code then? I assume there is simply a sinlg line of code to do this? THUS when something gets passed to this page as in the first part, then this will update the array and then refresh the page??? I HOPE? this is me
-
Yes, you can for an example pass the string of id:s in querystring to the new page:
window.location = 'MyPage.asp?items=' + items;
--- b { font-weight: normal; }Sheesss but you guys (oor maybe jsut you) really do know how to help a guy out.. THANKS again for the quick responce. OK I get the first posting you made and makes sence, but do I need to do the querystring pass or can I do it like first post only and then just refresh the PAGE 2 to display the updated array each time data has been passed to this PAGE? Mmm.. OK. So if I have one page (DB search) I can then send info from there to other page (SAME HTML FRAME SET IN DIFFERENT FRAMES) and update an array in the second frameset (second page) PAGE 1 is DB ( wILL NOT PASS db fIELDS OR ANYTHING LIKE THIS BUT THE SELECTION ON this page needs to be passed to PAGE 2's array) PAGE 2 is RESULT IF PAGE 1 send info to page 2 (FORM let's say) PAGE 2 GETS INFO AND AMENDS the array (ADDS to what it had before) So you can change PAGE 1 (DO MULTIPLE SEARCHES one after other) AND EACH RESULT PAGE SEND DATA TO PAGE 2 and PAGE 2 UPDATES the array (Not start a new array again) PAGE refresh will then on the PAGE 2 show the arrays NEW data after each FORM DATA send from PAGE 1. this is me
-
Yes, you can for an example pass the string of id:s in querystring to the new page:
window.location = 'MyPage.asp?items=' + items;
--- b { font-weight: normal; } -
Sheesss but you guys (oor maybe jsut you) really do know how to help a guy out.. THANKS again for the quick responce. OK I get the first posting you made and makes sence, but do I need to do the querystring pass or can I do it like first post only and then just refresh the PAGE 2 to display the updated array each time data has been passed to this PAGE? Mmm.. OK. So if I have one page (DB search) I can then send info from there to other page (SAME HTML FRAME SET IN DIFFERENT FRAMES) and update an array in the second frameset (second page) PAGE 1 is DB ( wILL NOT PASS db fIELDS OR ANYTHING LIKE THIS BUT THE SELECTION ON this page needs to be passed to PAGE 2's array) PAGE 2 is RESULT IF PAGE 1 send info to page 2 (FORM let's say) PAGE 2 GETS INFO AND AMENDS the array (ADDS to what it had before) So you can change PAGE 1 (DO MULTIPLE SEARCHES one after other) AND EACH RESULT PAGE SEND DATA TO PAGE 2 and PAGE 2 UPDATES the array (Not start a new array again) PAGE refresh will then on the PAGE 2 show the arrays NEW data after each FORM DATA send from PAGE 1. this is me
If you want to reload the second frame, you have to send all the accumulated items in the request. You can do this either using a hidden field in a form and posting the form, or passing it in querystring. You can use the value from the querystring to get the records from the database: strSQL = "select id, foo, bar from theTable where id in (" & Request.Querystring("items") & ")" Put the previously accumulated items in a string in asp and write it out in the javascript. Something like: <% strItems = "" While not rs.EOF strItems = strItems & "," & rs("id") rs.MoveNext Wend strItems = Mid(strItems, 2) 'remove first comma %> var items = '<%=strItems%>'; When you call the function that will reload the page, it will add the new items to the previously accumulated items, and send them all back in the querystring. --- b { font-weight: normal; }
-
Something in the function when adding to the array that just says this.refresh = refresh ??? Not going to work??? this is me
-
OK in more detail I have this. Pricelist.asp ASP page that simply does a shirt on the DB and displays the result in same page Choices.asp Frame to display the accumilative choices made in the pricelist.asp frame Price.htm the frameset containing the two ASP pages. Now user sees the two ASP pages and can then elect a qeury in pricelist.asp (In the TopFrame)which returns the result in the same frame (page) he can then select one or more of the qeury results and click a submit button which will then pass this result to the Choice.asp page (In the MainFrame) where that result gets added to the allready there array and displyed as soon as it has been updated. A this stage I know what I want passed etc and can get that into place, but passing seems to be done to the wrong page or frame or something ?? What would the pass be to the Mainframe on the Price.htm be? Is it Price.MainFrame or would it be just Mainframe from the Pricelist.asp or would it be Choice.mainframe or just choice I am clueless.. :) Sorry for this HELLUVA long thing, but sure you now know what I need? PS and any chance of keeping the answer for me in VB?? Not serious, but would help. I assume I can then pass the results from a form in Pricelist.asp to a Procedure in Choice.asp???? THANKS AGAIN FOR ALL THE HELP.. JSUT NEED THIS SORTED AND I CAN GET MY WEBSITE UP THEN.. REST IS WORKING FINE. this is me
-
OK in more detail I have this. Pricelist.asp ASP page that simply does a shirt on the DB and displays the result in same page Choices.asp Frame to display the accumilative choices made in the pricelist.asp frame Price.htm the frameset containing the two ASP pages. Now user sees the two ASP pages and can then elect a qeury in pricelist.asp (In the TopFrame)which returns the result in the same frame (page) he can then select one or more of the qeury results and click a submit button which will then pass this result to the Choice.asp page (In the MainFrame) where that result gets added to the allready there array and displyed as soon as it has been updated. A this stage I know what I want passed etc and can get that into place, but passing seems to be done to the wrong page or frame or something ?? What would the pass be to the Mainframe on the Price.htm be? Is it Price.MainFrame or would it be just Mainframe from the Pricelist.asp or would it be Choice.mainframe or just choice I am clueless.. :) Sorry for this HELLUVA long thing, but sure you now know what I need? PS and any chance of keeping the answer for me in VB?? Not serious, but would help. I assume I can then pass the results from a form in Pricelist.asp to a Procedure in Choice.asp???? THANKS AGAIN FOR ALL THE HELP.. JSUT NEED THIS SORTED AND I CAN GET MY WEBSITE UP THEN.. REST IS WORKING FINE. this is me
As I wrote earlier in the thread, you can use this to call a javascript function in a different frame: top.otherFrame.addItems('4,7,18,42'); Where otherFrame is the name of the frame and addItems is the name of the function. Just substitute the name of the frame you want to reach, and the name of the function you wish to call. --- b { font-weight: normal; }