Niccaman Posted May 30, 2009 Share Posted May 30, 2009 Javascript: if (temp == 1) { document.abortForm.submit(); } Form: <form name="abortForm" action="" method="post"> <div id="postLeave" style="width:100%; text-align:center; display:none; height:0px;"> <div style="width:100%;"> <input type="hidden" name="thisOp" value="1"> <input type="submit" name="submit" value="Confirm" class="output" style="width:50%;"> <input type="button" value="Cancel" class="output" style="width:50%;" onclick="cancelLeave()"> </div> </div> </form> I have tried variations of writing form submission in the javascript (that i know of), inluding: "document.forms[0].submit();", and have also tried giving the form an action. No JS errors reported with firebug. I stuck an alert statement in the if statement, and i know it gets there. So why does my form not submit? because of my hidden divs? i just dont understand. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 30, 2009 Share Posted May 30, 2009 What's temp? Is it equal to 1? Try document.forms.abortForm.submit(); Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 30, 2009 Author Share Posted May 30, 2009 temp is a variable which is equal to 1. I tried document.forms.abortForm.submit(); and abosultly nothing happens. No form submit. This is such an irritating issue irritating. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 30, 2009 Share Posted May 30, 2009 Can you post your entire code please? Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 30, 2009 Author Share Posted May 30, 2009 function refreshTranscript(num) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="/organised/transcript.php"; url=url+"?id=1&opid="+num; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=function stateChanged8() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var temp = xmlHttp.responseText; if (temp == 1) { document.forms[0].submit(); }else { var before = document.getElementById('transcript').innerHTML.length; document.getElementById('transcript').innerHTML = temp; var after = document.getElementById('transcript').innerHTML.length; if (!(before == after)) { scrollChat(); } setTimeout("refreshTranscript("+num+");",10000); } } }; xmlHttp.open("GET",url,true); xmlHttp.send(null); } .... its basically an ajax chat element. the part we are discussing is when the chat is closed, the php file will return 1 which is stored in 'temp'. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 Remove "stateChanged8". Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 with the result just being " = function ()" still nothing happening. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 Niccaman, posting "nothing happening" doesn't help us know what went wrong. Does the AJAX resolve? Are you getting the else case instead of the if case? If you do alert(temp), does it alert? I assume nothing happening means your AJAX failed, meaning literally nothing happened. Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 Lol no, as im sure i said earlier, i know the if statement is fulfilled as i tested it with an alert already. The else part (actual chat feature) works perfectly. I confirm that the if statement is fulfilled. When i say nothing happens i mean absolutly nothing happens. I have a firefox web developer toolbar which reports no errors of anykind including javascript. The code gets to the submit code line, and im assuming it executes it successfully with zero effect. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 Do you have this up on a live site I can see? Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 Yes, but requires some effort to fulfill the condition. www.rogueagents.org ...you'll need 2 accounts fulfill the condition. firstly go to "Organised Ops", then create a lobby with this username: 'FestiveSix' pw: 'asd' (this player has enough game-money to do this). Then join the lobby with your account, and have festivesix abort the 'Op'. When the op is aborted and a user is still inside the lobby, the chat feature will return 'temp == 1', this will consequently submit the page to leave the lobby, in order to ultimately prevent 'ghost' messages in the database. If you cant be bothered with all that i will understand Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 Well, mind creating 2 accounts for me? I rather not have to put up 2 emails to get them verified. Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 testing1 password is asd like festivesix both accounts are sufficient Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 How do I join the lobby with testing1? Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 invite him with lobby leader (festivesix) or find the lobby using auto join/advanced search feature. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 So if I got this right, the procedure is - 1. Log in as FestiveSix 2. Click 'Organised Ops' at left panel. (spelling error on organized) 3. Invite testing1 to say 'Intelligence Expert'. 4. Click Abort Operation button? Do I do anything with the Chat button? Sorry, I just want to make sure. Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 yes, but abort with lobby leader (festivesix) whilst having the lobby on screen for the other user (testing1). the chat refresh does so every 10 seconds, alternatively, you can try and chat in order to activate the form submit. Both events will cause 'temp == 1'. if you chat you will trigger 'function transcript(num)' with 'document.abortForm.submit();' if you wait for refresh you will trigger 'function refreshTranscript(num)' with 'document.forms[0].submit();' ... (I left 2 different codes from 2 different events so that you can see both times fail). remember, the condition will only be fulfilled if you do not navigate away from the page after aborting with the other user. (Also, organised is the correct way to spell in the english dictionary - British) Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 I clicked Abort Operation and I got this Confirm thing. What should I do? I don't want to click the wrong one and have to wait 12 hours. Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 lol dont worry, i temporarily disabled the 12 hour effect so that i could programme this in. just abort it, retry as many times as you want. I can always enter in more money. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 Firebug error - document.getElementById("transcript") is null [break on this error] var before = document.getElementById('transcript').innerHTML.length; Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 that error only occurs in the else part of the if statement. it has no reprucussions and only occurs when chat box is empty. it should bear no effect on anything else. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 So that means I missed the if statement? How do I trigger that? I did exactly as you told me to do. Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 standard behaviour is for the else statement to always occur. Rather you missed the if part if anything. The if part is fulfilled when you abort the operation with the leader, whilst being in the lobby (the part with the chat box from the op you just aborted) with another user. IF the op has been removed from the database (s=effect of aborting) the other user isnt meant to be on the page, and the submit is a method of notifying the user. The if part is fulfilled in order to have this effect, though right now, nothing happens. ..basically, when you abort, the if statement is fulfilled with the OTHER user. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 Something's weird with the form. But I'm not going to track down why right now. Since it doesn't work, try this - document.forms.abortForm.submit.click(); Quote Link to comment Share on other sites More sharing options...
Niccaman Posted May 31, 2009 Author Share Posted May 31, 2009 That didnt work but it gave me an idea. i simply got the submit button which is used by the user, and clicked it with .click(); solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.