I want to show message using dynamic action say this data already exist
after check the database
i tried to do that using excute server side code then alert
i tried to use trigger and automation
You didn't describe what you're doing so I'm assuming this is a form region and you want the message to appear on change of the page item.
Here is an example with a form on the EMP/DEPT sample data. Functionality is that on change of the item P59_ENAME, a dynamic action fires and shows a javascript alert if the ename already exists. In my case this is page 59. I tested this on apex 21.2
Create a form on table EMP
Create an additional page item of type "Hidden" named P59_ENAME_EXISTS
Create a dynamic action on the item P59_ENAME
Add a first true action to execute the pl/sql code. This will set a value for the page item P59_ENAME_EXISTS (Y if ename exists, N if it does not exist). Note the "items to submit" and "items to return" values - those are very important.
Add a second true action to show the javascript alert if ename already exists. Note the client side condition.
Add a 3rd action to reset the value of page item P59_ENAME_EXISTS
Run the form, change the ENAME to an existing value and click in another field on the page. You'll get the popup.
Triggers or Automations cannot be used to achieve this functionality.
Related
i am trying to reset values of variable in google tag manager when particular tag fires
example:
action : add-to-cart
when 'add to cart' button is clicked then via datalayer i am pushing product data to gtm. this data i am storing in different variable such as - productid, productname ,productprice.
now when add to cart button hits then this variables will fill with data.
after that i have created one tag which sends this variable to 3rd party site via tag.
tag name : send-data-to-3rd-partysite
tag type : custom html
tag trigger - productprice does not contain undefined.
it means when productprice does not contains undefined then this tag should fire. (at start it contains undefined )
but problem is that when one 'add to cart' button is hits then the variable contains those product data for entire session and when another add to cart button hits then the data is replaced by new one. problem is here that 'send-data-to-3rd-partysite' fired when productprice contains some value. it does not fires becuase of productprice is not undefined.
so what i want is when 'send-data-to-3rd-partysite' tag fires then 'productprice' variable should be reset or clear.
i tries below code in send-data-to-3rd-partysite tag but did not work
<script>
...
window.google_tag_manager[{{productprice}}].dataLayer.reset();
<script>
Try not to reset the dL. It leads to complete flush and that's not a very good thing to do, considering how DL is supposed to be used.
What I saw people doing and it works pretty well, however flimsy looks, is making a custom HTML tag where they push undefines into the DL, effectively overwriting the old values.
In your case, it would be something like dataLayer.push({productprice : undefined})
Now you use timing rules to always fire this tag after the tag that uses productprice has fired and there you go, your cleaning logic is in place.
I just want to mention that if you have to clean up DL like this, then your tracking architecture is a wreck. This must be viewed as a hack and not an elegant one.
I'm changing the items in an ASP.NET DropDownList using jquery, but when I submit the form, the SelectedItem property of the DropDownList is null. Any idea how I can modify the list of items in the DropDownList with jquery without causing this error in the code behind?
Here's the way I'm setting up the DropDownList. Initially, it's an empty ASP.NET DropDownList.
var mailType = $("#ContentPlaceHolder1_ddlMailType");
mailType.empty();
mailType.append("<option></option>");
mailType.append("<option value='D'>Direct Mail</option>");
.
.
.
The DropDownList does end up showing the added items after the jquery executes.
Sorry, you cannot use jquery or Javascript to add items to a server-side ASP.NET web forms list control. The contents of the list control are stored in ViewState, and unless you've done something very strange, your jquery is not updating the ViewState. If you have validation enabled, ASP.NET will throw an error if the form post tag/value does not match any of the known values that are stored in ViewState.
If you wish to have listbox with items that are added dynamically on the client side, don't use a server side control. Just type the HTML into the ASP web form directly (don't use the runat=server tag). To read the contents of the control on postback, don't reference the control; instead, use HttpContext.Request.Form["tag name"]. Note that there is no way for your code behind to know what your jquery has added to the list box, as this information is not passed when the browser posts the form-- only the value attribute of the selected item is passed.
For some more related information, see one of my other answers here.
Couple of things you should check. 1) Modify your JavaScript to get the drop down client id dynamically. The client id changes with every post back event.
var mailType = $("<%= ddlMailType.ClientID %>");
mailType.empty();
mailType.append("<option></option>");
mailType.append("<option value='D'>Direct Mail</option>");
Also, 2) If you are binding the original values of the drop down list in code behind make sure you are handling the post back event. Otherwise the drop down will reset to its original value each time there is a post back.
If Not Page.IsPostBack Then
ddlMailType.databind()
End If
your control is declared with no items in the aspx. since nothing is added to the items collection that way and no adding to items is done in page_init or page_load (when IsPostback = false) when a postback occurs to check SelectedItem, the items property of your DropDownList is empty.
you can still get the value from the forms collection Request.Form[MyDDL.UniqueID]
more in depth here.
Why does DropDownList.SelectedValue is relied on viewstate?
I have an apex application where I want a button to trigger a dynamic action. The action would be comprised of three parts:
1. Javascript to prompt for some value
2. PL/SQL to insert a row in a table including the value from 1
3. submit page
I can get the prompt to work but when step 2 runs it does the insert using the previous value from #1. For example if I hit my button twice, the first time I get nothing inserted into that column and the second time I get the value I entered the first time I was prompted.
Javascript action:
$x("P2_REJECT_REASON").value = prompt("Please indicate your reason for rejecting this request", "");
PL/SQL action:
begin
INSERT INTO PDD_APPROVER(PDD_ID,STATUS,REASON)
VALUES(:P2_PDD_ID,'REJECT',:P2_REJECT_REASON);
end;
The reason why it is always one value behind is because of your page submit. The page submit will set the session state of the item to the submitted value. When your page has rendered again and the dynamic action fires, the session state of the item is still that of the value submitted during the last page submit.
If you want the value of a page item to be available in the PLSQL code of the dynamic action, you need to submit the page item to the session state when the call occurs. Do not forget that session state does not necessarily match the value of the item on the page. The page item is on the actual rendered page on a client, while session state resides in the database on the server. Since PLSQL is code ran on the server, you need to provide the values used.
You can add the item to the "Page items to submit" field of the "Execute PLSQL" action.
However... Why would you first perform a plsql action and then submit the page? That is totally pointless. It'd be far better to conditionally perform a process on page submit than to first execute a piece of plsql (synchronously even!) and then submit again!
Scene : I have a ASP.Net 2.0 app that I need to add functionality to. I need to loop through a gridview's items and compare them to another gridview, If they exist in the other, I must pop up a confirm message to increment the qty. I couldnt find alot on ASP 2.0 so i decided to user a hidden asp field to store what i am processing and based on that registering a clientside script to change the hidden field value and then simulate a postback (I have tried _doPostBack()). So whats happening now is I am trying to access the asp button to simulate a click, but the javascript gets a Null instance everytime. Please advise. (For the testing, i try to alert the button instance, which returns null)
ClientScript.RegisterStartupScript(GetType(String), "ConfirmationScript", "if (confirm('This item already exists, Increment the qty?') == true) {alert(document.getElementById('<%=btnAddSpecificLine.ClientID%>'));}", True)
Try your test like this:
ClientScript.RegisterStartupScript(GetType(String), "ConfirmationScript", "if (confirm('This item already exists, Increment the qty?') == true) {alert(document.getElementById('" & btnAddSpecificLine.ClientID & "'));}", True)
Since you generate this code server-side - pass ClientID directly
Goal: User enters one item in text box that has autofill, after clicking button they are taken to a second page that has other corresponding items already filled out in form.
Problem: Autofill works but becomes erased/wiped out when second page opens (in other words the form is blank.
Question: I suspect I am not properly associating the actions of "form auto fill" and "open second page" with the one button. Any ideas?
$("#nextbutton").click(function () {
$("#favorite_appetizer").trigger("meals");
window.location.href = 'dinner-ideas.html';
});
Well probably problem is already solved, but try adding $_GET into javascript href, like:
window.location.href = '/index.php?first=1&second=2';
Part in part after you declare variable names and values that you can catch in second php page, like:
$_GET['first'];
$_GET['second'];
Ofcourse you need to get values from form elements with .val() or .text() and etc.
And ofcourse this has drawbacks, best used for numbers and words but not texts with symbols. Knowing more about type of form content would help, like if its data to be saved to database, you could AJAX half filled form, then retrieve its data from database with a query. If you are just filtering data, you can URL $_GET database ids of form elements, then query in second page by those ids. So again, depends on data in your forms that you want to pass to second page.