Changing ASP Included file and saving choice as a cookie - ajax

Ok, so I'm in the process of expanding my knowledge and need a step in the right direction, not necessarily an answer.
I am wanting to create a script for my eCommerce site that lets users choose between grid and list view on product listings pages.
The grid view will be called using an included file called "incgridview.asp" - the list view file is called "inclistview.asp".
Upon the user choosing an option from the drop down specifying which type of view they want, the respective file should be called. So if they select grid view, I need to load the incgridview.asp (list view will be loaded by default).
Once the selection is made, I need it to switch the view without reloading the page, and store a cookie for 7 days that remembers their selection. Of course, they would still have the option to switch back to the other view.
So basically I am switching which file is included upon user selection of the drop down. Im thinking maybe I need to use ajax but not sure. Any help is greatly appreciated. Thanks!
EDIT
Ok, so this is what I am trying to use, on my file that actually includes the grid pages. It is throwing up this error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: '[object]'
/productsviewtest.asp, line 59
Dim listgridcookie
listgridcookie = Response.Cookies("atdviewcookie")("viewoption")
Select Case listgridcookie
Case "list"
print"list view"
Case "grid"
print "grid view"
Case Else
Response.Cookies ("atdviewcookie")("viewoption") = "grid"
Response.Cookies ("atdviewcookie").Expires = DATE + 7
Response.Redirect(Request.RawUrl)
End Select

here is a steps on your page load:
1) Check if cookies exists and what values are there, if it does not exists - create one with default value.
2) Based on value from cookies show div which has been loaded with data from proper include file.
3) When/if selection changes create/re-write cookies with expiration time you desire.
All what you need to build is JavaScript based switch to show one element and hide another.
If you like to use AJAX or JQuery - you can do it this way but for my taste it take away challenges of creating something you can be proud of.
This is based on your " page must not be reloaded upon changing selection" statement.

Related

Oracle APEX takes a value from a function and uses it to open a new page

I have a function that returns a value (e.g.27).
I am put this value to my page item (P2120_SYMPTOM_ID) and i want with this value to open with button another page (P2140).
I am going to button Link builder - target and i am using P2120_SYMPTOM_ID like this:
but unfortunatendly this value doesn't pass to my new page criteria.
How can i use this value?
If you're just navigating to another page (as opposed to opening a modal window) then use action "Submit" on your button and create a branch to the new page. That is how navigation is supposed to be done. The link builder links are generated when the page is rendered and do not pick up session values.
This is a common question, and relates to the fact the link uses values during page render, not what may have happened during interaction with the page
A common solution is presented in the Oracle forums here
https://community.oracle.com/tech/developers/discussion/3725149/pass-client-side-state-to-modal-dialog
Alternatively, there is a free & supported FOEX Redirect plugin that also solves this problem
https://fos.world/ords/f?p=10000:1080

Oracle apex value of item is not up-to-date in button link builder when using redirect to another page

I have a value of a field on page 1 that I need to pass to page 2 (modal dialog).
The field is changed on page 1. and I can see it's got updated on the page and when I print its value in debug messages.
When I'm clicking the button, with the action "Redirect to Page in application", the value on page 2 is the initial value of the field, and not the updated one, is this a bug?
what can I do?
I don't want to use dynamic action or things like "prepare_url" because of many reasons.
Thanks.
That is not how a link works. What you are seeing is not a bug, it is expected behaviour. The link is rendered when the page is rendered and will have the item values at render time and a calculated checksum (depends on settings) based on those values. It will not pick up any changes.
The "traditional" way to do this is the following. Assumptions: Need to navigate from page 1 to page 2 and set P2_ITEM on page 2 to value of P1_ITEM on page 1.
Create button (let's say button name is MYBUTTON) of type "Submit Page"
Under "Processing", create a branch to page 2.
For "Page or URL" pick page 2 and set P2_ITEM to value P1_ITEM.
For "Process point" pick "After Submit"
Under "Server Side Condition", select "MYBUTTON" under "When Button Pressed".
Since this is a branch your page has been submitted and all the changes you made to P1_ITEM will be picked up. The fact that page 2 is modal does not affect this, APEX will take care of that for you.
As an alternative to Koen Lostries excellent explanation, in some cases it is also possible to have the target page load the item from the source page.
Ensure that the item is being pushed to the session, for example by using a dynamic action with the items to submit option, but do nothing else in this dynamic action.
Then, when page 2 opens, simply add a pre-header-process, that makes something like :P2_ITEM := :P1_ITEM;
In my experience this approach is easier than doing a redirect in a dynamic action, as there is no declarative option for that and you often need hand-written javascript to do that.

COLDFUSION CFGRID Datapass with a post

I have a bit of a unique challenge today. I have a client that wants to be able to search for multiple items based on inserts into a cfgrid. Suppose we have the following web form:
A Country selection dropdown
A State Selection dependent AJAX dropdown
A city Selection dependent AJAX dropdown
An ADD Button
----------------------------------------------------
A CFGRID that will populate a row with selections when the user clicks the add button
----------------------------------------------------
And finally, a CLEAR button, and a GO button on the bottom.
The resulting page will then query the database and get some statistics about the cities selected. So, suppose an individual picks USA > Arizona > Scottsdale and USA > Arizona > Flagstaff. The grid below the options will 'save' each selection and reset to their default options, waiting for a user to pick additional options or click on 'GO'.
The resulting page will then generate columns that list some statistics about the communities and highlight the 'best of' between each selected community.
Each time a user selects the ADD button (assuming three criteria are selected) I want the information to be added into a CFGRID that displays the options selected. Then, After the user selects at least one country/city/state option, have all of the data in the CFGRID get passed to another page that does a query from the data selected. In theory, the user could pick as many communities as they want, assuming they are willing to let the database sludge through enough data to get what they want and wait through a 'loading' screen to get it.
I'm having these challenges, in no particular order:
- I have an HTML grid that I must use per client spec (No Java or Flash, must be HTML)
- I have no idea how to get the selected options into the CFGRID. I assume there is some JavaScript I can write that uses some sort of AddRow function to add data into the grid with the add button but cannot seem to find how to it on the interwebs
- After we conquer the above challenge, how do I pass the data from the grid into the results page? I thought about passing one big string or a structure, but I'm not sure how to do that through the URL or posting, nor how to get the data out of the grid. I wonder if I am better off coding some sort of string that gets passed from the options page to the results page with a get method instead of dealing with the stuff in the CFGRID and have the CFGRID serve only as a 'dummy' display container.
- Finally, after the pass is complete, I would need to loop through through the structure and perform a CFQUERY or CFSTOREDPROC on each row of data, then get the statistics I need to display on the results page. I assume this would depend on how I am getting the data from the options selection page to the results page.
THANK YOU ALL!
CFGRID is great to start, but it can be b*tch to customize and extend... Have you tried editable CFGRID with bind? See how far off it is from what you want first. If it turns out to be very far, then you might want to go for a jqGrid and code up some jQuery.
To start, read Using HTML grids and make the cfgrid editable.
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a01.html#WSc3ff6d0ea77859461172e0811cbec22c24-72e0
Once you got that working, look at these provided JS functions that you can use with CFGRID
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS0ef8c004658c1089-6262c847120f1a3b244-8000.html
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSd160b5fdf5100e8f-4439fdac128193edfd6-7f5f.html
If you still demand a bit more, you might need to dig into the underlying ExtJS component. At that point I would rather use jqGrid
I found out that the best way to handle this was by using a SerializeJSON call and a Deserialize JSON call back and forth. By using JavaScript notation we are able to pass a complex JavaScript object (array) between one page and another. This has the value add of not having to worry about sessions timing out and making URLs clickable from one solution to the next.

How to design this page in razor world

In MVC-3/Razor, I need to create a page which will have five set of controls. Each set will have a drop-down and a text box. User will select an option from drop-down and then provide some feedback on text box.
When the view is shown very first time, I only have to enable controls in first set. Whereas all controls in 4 other sets should be disabled. Once user perform action in first set of controls (select optino from drop-down and enter in text box), the second set should become enable now, whereas other set of controls should still be disbaled. The data shown in this second drop-down is dependent upon what user has selected in first drop-down. Once user complete action in this second set, the data in third drop-down will depend upon whatever user selected in first and second drop-down etc.
I am a web-form aspx developer and not sure what will be the best way of designing this in MVC-razor world (because there is not view state etc).
Step 1)
What needs to be clarified is what will cause the other “sets” to be enabled?
Is it after the user has selected an item in the dropdown
OR
Is it after they have entered some text in the textbox?
What also needs to be clarified is if you have a dropdown AND a textbox are they both enabled at the same time or is the textbox only enabled after you’ve selected an item in the dropdown?
Once you’ve got that figured out, move on to the next step.
Step 2)
Do the users need to visually see the 4 sets from the beginning (disabling the 3 other sets) or can you simply show the other sets (on the fly) once the previous one has been successfully filled?
Depending on the answers, this may vary your approach.
As for me, the way I’d do it is simply have/show one set that loads at the beginning.
Once the user has selected an item from the dropdown, I would make an AJAX call passing along the selected item and get back a list of values for the second dropdown.
Then, using jQuery, I would duplicate the row (or div) of the first set all while changing the values in the second dropdown box.
Repeat process for when an item is selected in the second dropdown.
But wait! There’s more!!!
Let’s assume you’ve reached the third set. What if the user decides to change the value in the first dropdown? What are your requirements if that happens? Should you remove all other sets and start back at square one? I guess so…
Since we are not aware of the full set of specs for your tasks, we can only assume stuff and this may (or not) be the best path to take.
Duplicating a row (or a div) using jQuery is quite fun and performance wise, it’s nice.
Keep in mind, you will have to give a different ID to your controls (dropdown + textbox) so when you submit the form, you could use the FormCollection to get those dynamically generated controls.

Update Drupal views argument via AJAX

I have a request concerning Drupal 6.x
I'd like to have this behaviour:
imagine to have 2 columns, on the left a list of nodes (only titles for example) and on the right a view showing just one of the contents on the left.
My idea would be to achieve this with an AJAX-fashion: clicking a link in the list on the left updates the view on the right with the actual node.
Which is the best way to handle this?
My idea is to use Panels, make 2 column panel with 2 views, one (left) filtered on content type, with no arguments, and one on the right which takes in as an argument the node id to be displayed.
But how to link the 2 views with AJAX?
(or, better, how to update the view on the right with an AJAX call?)
is this possible?
Any help or idea is really welcome
Thanks!
Cheers
Mauro
You also can do a quick hack, which is quite flexible, because it allows you to change your views without changing code.
I have had a similar task recently and for your task I would do the following:
for your right column, create a exposed filter (node id) and hide whole exposed filter form using CSS.
using jQuery, attach a click behavior to titles on your left column.
the click behavior takes the node id, finds the attached exposed filter at the right column, enters the node id into the input field and executes form's .submit().
the .submit() triggers the build-into-views well debugged ajax request which refreshes your right column.
this is certainly possible, and not very difficult to do.
Your task can be divided into two main parts:
Providing a 'callback' URL in the Backend that takes a node id (nid) and returns the markup to display the node in the right panel in a format that can be processed by javascript. This will be done in PHP within a normal Drupal module. The main point is not to return a full Drupal page as usual, but only the markup for the node.
Create logic for the Frontend that, when triggered by clicking a link in the left panel, retrieves the new node markup via the URL callback above and replaces the content of the right panel with it. This needs to be done in javascript, using the Drupal javascript API with jQuery.
You can find an introduction and example for AJAX in Drupal here. (This does almost exactly what you want to do, only with images)
You should also look at this more general entry point for JavaScript in Drupal.

Resources