Jump to content

jquery close a popup and update a parent


Renlok

Recommended Posts

well i have the code

$(document).ready(function () {
var num_images = $('#numimages', window.opener.document).val();
var now_images = {NUMIMAGES};
var image_cost = {IMAGE_COST};
if (num_images != now_images) {
	var fee_diff = (now_images - num_images) * image_cost;
	$("#to_pay", window.opener.document).text(parseFloat($("#to_pay", window.opener.document).text()) + fee_diff);
	$('#numimages', window.opener.document).val(now_images);
}
});

but it doest seem to work just makes the window crash the full javascript on the page is

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var num_images = $('#numimages', window.opener.document).val();
var now_images = {NUMIMAGES};
var image_cost = {IMAGE_COST};
if (num_images != now_images) {
	var fee_diff = (now_images - num_images) * image_cost;
	$("#to_pay", window.opener.document).text(parseFloat($("#to_pay", window.opener.document).text()) + fee_diff);
	$('#numimages', window.opener.document).val(now_images);
}
});
</script>
<!-- IF B_CROPSCREEN -->
<script type="text/javascript" src="js/jquery.imgareaselect.js"></script>
<script type="text/javascript">
function preview(img, selection) {
var scaleX = {SCALEX} / selection.width;
var scaleY = {SCALEY} / selection.height;

$('#thumbprev').css({
	width: Math.round((scaleX / {IMGRATIO}) * {IMGWIDTH}) + 'px',
	height: Math.round((scaleY / {IMGRATIO}) * {IMGHEIGHT}) + 'px',
	marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
	marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
});
$('#x1').val(selection.x1 * {IMGRATIO});
$('#y1').val(selection.y1 * {IMGRATIO});
$('#x2').val(selection.x2 * {IMGRATIO});
$('#y2').val(selection.y2 * {IMGRATIO});
$('#w').val(selection.width * {IMGRATIO});
$('#h').val(selection.height * {IMGRATIO});
}

$(document).ready(function () {
$('#save_thumb').click(function() {
	var x1 = $('#x1').val();
	var y1 = $('#y1').val();
	var x2 = $('#x2').val();
	var y2 = $('#y2').val();
	var w = $('#w').val();
	var h = $('#h').val();
	if (x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h=="") {
		alert("You must make a selection first");
		return false;
	} else {
		return true;
	}
});
});

$(window).load(function () {
$('#thumbnail').imgAreaSelect({ aspectRatio: '{RATIO}', onSelectChange: preview, x1: 0, y1: 0, x2: {STARTX}, y2: {STARTY} });
});

</script>

 

if thats of any help and the {NUMIMAGES} are variables that a phrased in by php when the page is loaded

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.