Reputation: 35
To be honest I don't know JavaScript at all. I've been getting by figuring out things by looking at others but not this time! I would like one of my forms to pop-up centered on submission. I have gotten it to pop-up and retain the form data so far but I cant seem to get it centered! Here is some of the code Im working with:
Also if someone could explain this to me that would be great. My form action looks kinda crazy with the document.getElementByID('Name").vaule plus the email and so on but the form field ids don't match with the action but IT STILL WORKS. I have no clue about that one or why it actually works still. http://www.computerbytez.com/develop.html for the form in action!
Form:
<form action="https://computerbytez.com/InstantChat/Standard/logmein.html?Name=' + document.getElementById('Name').value + '&Email=' + document.getElementById('Name').value, '', 'toolbar=no, status=no, menubar=no, titlebar=no, location=no, scrollbars=no, resizable=no, height=500, width=400'" id="lmiform">
<div class="form-field">
<label class="cm-required " for="elm_7">Name</label> <input class="input-text" id="elm_7" name="name" size="50" style="width: 100%; max-width: 372px;" type="text"/></div>
<div class="buttons-container">
<span class="button-submit button-wrap-left"><span class="button-submit button-wrap-right"><input type="submit" value="Connect To Technician" /></span></span></div>
Form JavaScript:
$(document).ready(function() {
$('#lmiform').submit(function() {
window.open('', 'formpopup', 'width=620,height=480,scrollbars=no,resizable=no,top=200,left=200');
this.target = 'formpopup';
});
});
I also have been messing with this (popup center for a link) and I've been trying to combined the two with no luck:
<script>
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
<a href="javascript:void(0);" onclick="PopupCenter('example.html', 'myPop1',620,470);"><img alt="" class="LMIpic" src="live_help_online.gif" /> </a>
Any help would be greatly appreciated. Thanks
Upvotes: 0
Views: 415
Reputation: 1076
I've visited your site, and the popup shows up centered and fine for me when clicking the image. The code looks fine. Try clearing your browser cache.
Edit:
$(document).ready(function() {
$('#lmiform').submit(function() {
var left = (screen.width/2)-(620/2);
var top = (screen.height/2)-(480/2);
window.open('', 'formpopup', 'width=620,height=480,scrollbars=no,resizable=no,top='+top+',left='+left);
this.target = 'formpopup';
});
});
Upvotes: 4