Passing data from popup to page - javascript

i have a basic form where the users of an ERP can create ticket for quick support. In the form they have to put the client ID, but i want them to click a search icon to open a pop up (or something similar) and select the client.
In the pop up i want to load a list of client, and when they select the client, send de ID to the main page where they are creating the ticket...
How can i do this?

I use the next script to send data from child to main page:
$("button").click(function() {
var data = $(this).val();
window.opener.document.getElementById('cliente-nombre').value = data;
window.parent.close();
});
and in the button wich open the popup:
function openNominaCliente() {
window.open("/clientes/nomina", "popupId", "location=no,menubar=no,titlebar=no,resizable=no,toolbar=no, menubar=no,width=500,height=500");
}
Thanks all!

Related

Laravel: how after creating stay at the page to create one more item

For example: I'm on Create Company Page. I need: when the user clicks “create” will be show modal window “Company successfully created. Do you want create one?” and buttons “No, thanks”, “Yes”
If the user clicks “No, thanks” he will be return on the Page Companies (index page, there are all Conpanies shown).
If the user clicks “Yes” he will be stay on current page for create new Company.
My method to store Company:
public function store(StoreCompanyRequest $request)
{
$company = Company::create($request->all());
return redirect()->route('admin.companies.index');
}
How to realize js modal window in create.blade.php and what to return in store method (prevent redirect or no)?
Front end interaction like this is usually done using Javascript. You would capture the submit button click, then show a modal and post to the server to save your new customer.

How to hide div in html page in app.js

After login I am showing some user modules on html page. I want to hide it when user not have an access for that module by admin. I am use sencha/ ExtJs for front-end.
I want to hide this component after user login if he don't have permission for it.
here is my code(please see below Image)
I want to hide this Live Tracking On user login if user don't have access for this.
Design for this is bellow
I want to Create a function in App.js (In controller).
Can you help me for this...
Whenever you are validating the user or when it logs in, whenever that happens add style display:none
using javascript
document.getElementsByClassName('live-tracking').style.displ‌​ay= "none"
Your controller {
validateAndLogin : function () {
var isValidated = // check validation according your requirement.
if(isValidated) {
//display your html view and do following after adding id attribute to that
//div which you want to hide.
document.getElementById('livetracking').style.display='none';
}
}

How can I pull HTML data from a site that requires a button click?

I'm trying to write a script that will pull schedule information from a website by using Google Scripts. Using UrlFetchApp I can retrieve the raw HTML string from the target URL and have it output it to the log.
function myFunction() {
var options ={
"validateHttpsCertificates" : false
};
var response = UrlFetchApp.fetch("https://www.cnatra.navy.mil/scheds/schedule_data.aspx?sq=vt-31",options);
Logger.log(response.getContentText());
}
The obstacle I'm facing is that once the page loads, the schedule won't appear until the View Schedule button is pressed. The button is a "submit" input. Is there any way I can add a POST payload to my function to either simulate a button click or trigger the submit as the button would have? Or is it possible instead to pass the button click through a URL parameter? Here is the website.

How to send an email to someone from a button click on a web page

I have a photo frame designer. The user can select different options for their photo frame and they will be reflected in a visual svg-powered graphic. I need the options the user has selected to be saved and then passed on to the manufacturer. The most obvious way to me is to store their choices in javascript variables and then when an order button is pressed these variables are sent to the manufacturer's email. How achievable is this? And how does the email part work? Here is a snippet of code.
$(document).ready (function() {
$('#purple').click (function() {
$(".border").css("fill", "#763d81");
var frameColour = "purple";
});
});
Sending email is a server side functionality..You can check out your server side API for this. Ex: Java mail API
http://www.oracle.com/technetwork/java/javamail/index.html

How to return value from html popup

I need a terse, clean way to implement this in asp.net mvc (+/- jquery or js)?
User clicks an element in webform A;
Webform B pops up;
User interracts with webform B;
On closing webform B, probably by a submit button, the source element in webform a is updated with a value from webform B
Thanks.
With ASP.NET MVC, I'd probably render a DIV on the page, initially hidden, perhaps via AJAX if the contents depend on values selected on the initial page. I'd use the jQuery UI dialog plugin to popup the dialog. The dialog could contain a form that submits back to the server. You could also use the onclose handler for the dialog to both copy values from the inputs in the dialog for use on the rest of the page. If you populated the dialog via AJAX you could have the server generate the HTML -- say by rendering a partial view and returning it -- or return json and generate the dialog on the fly in the browser.
I've resorted to using cookies. I've found this to be the only reliable way to do this. I'm using GrayBox for my dialog, so I have a function in the dialog that looks like this:
function selectValue(id, name) {
SetCookie("_someuniqueprefix_RetID", id);
SetCookie("_someuniqueprefix_RetValue", name);
parent.parent.GB_CURRENT.hide();
}
Then in my calling page I am launching the dialog which displays a partial in the GrayBox:
$(function() {
var selectUrl = '/_somecontroller/Select';
// attach a method to the chooseButton to go and get a list of
// contact persons to select from
$("#chooseButton").click(function() {
GB_showCenter('Select My thing', selectUrl, 500, 620, function() {
var id = GetCookie("_someuniqueprefix_RetID");
var value = GetCookie("_someuniqueprefix_RetValue");
DeleteCookie("_someuniqueprefix_RetID", "/", "");
DeleteCookie("_someuniqueprefix_RetValue", "/", "");
$("#MyID").val(id);
$("#MyName").val(value);
});
});
});
Also you'll need to grab a function off the web for SetCookie and GetCookie
Hope that helps
You can use javascript from the popup window to call functions on the opener via window.opener. So your popup could call a function on the parent page to pass the data back when the user clicks the submit button.
I'm not sure what your requirements are, but IMO using ajax for this sounds like overkill. If all you need is some form data from the popup webform passed to the opener webform, then there's no need to make a call to the server.

Categories

Resources