You need to sign in to do that
Don't have an account?

Ask a question with jquery when record is opened
Hi There
I want to have a question presented to the user if a field is blank. I understand that ill need a VF page on the record which calls a jquery popup where the user can make the section. The popup would only show if 'field1' is blank, if the users selects yes then it would write yes to field 1, if they select no then it will write no to field 1. I will need to add an if statement to the start of the script.
So far i have made a VF page and put it on the opportunity however the VF page just displays the script in text, it does not execute it. At this stage im just trying to make the popup appear.
This is a mashup of some scripts if found on here. Any help is appreciated.
I want to have a question presented to the user if a field is blank. I understand that ill need a VF page on the record which calls a jquery popup where the user can make the section. The popup would only show if 'field1' is blank, if the users selects yes then it would write yes to field 1, if they select no then it will write no to field 1. I will need to add an if statement to the start of the script.
So far i have made a VF page and put it on the opportunity however the VF page just displays the script in text, it does not execute it. At this stage im just trying to make the popup appear.
This is a mashup of some scripts if found on here. Any help is appreciated.
<apex:page StandardController="Opportunity"> <script type="text/javascript" src="/js/functions.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> window.document.onload = new function(e) <script> try{ jQuery(function() { /*Append the jQuery CSS CDN Link to the Head tag.*/ jQuery('head').append('<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/start/jquery-ui.css" type="text/css" />'); /*Create the HTML(DIV Tag) for the Dialog.*/ var html = '<div id="dialog" title="Question 1 Title"><p>Question 1</p>Some supporting test.</div>'; /*Check if the Dialog(DIV Tag) already exists if not then Append the same to the Body tag.*/ if(!jQuery('[id=dialog]').size()){ jQuery('body').append(html); } /*Open the jQuery Dialog.*/ jQuery( "#dialog" ).dialog({ autoOpen: true, modal: true, show: { effect: "highlight", duration: 1000 }, hide: { effect: "fold", duration: 200 }, buttons: { "Yes": function() { location.replace('/home/home.jsp'); jQuery( this ).dialog( "close" ); }, "No": function() { location.replace('/home/home.jsp'); jQuery( this ).dialog( "close" ); }, Cancel: function() { jQuery( this ).dialog( "close" ); } } }); }); } catch(e){ alert('An Error has Occured. Error: ' + e); } </script> </apex:page>
You <script> tag (line # 9) should be before the windows.document.onload call. All javascript & jqueries should be inside <script> tags. Hope this helps.
I have moved the <script> from 9 to 7. While the text is no longer output there is no script running at all now.
I have a similar code that you can modify
Please note that the above code is tied to a button with id "a", replace this with button in your page.
Hope this helps
Thanks :)