Wondering how to add in js script a three more !== or statements. The following script was provided as a spectacular answer by jsfriend00 but the problem is I made the mistake of not mentioning there's three more textareas unaccounted for. I'm stuck with the javascript on the remaining or !== conditions. In the following script how to take say !== to each of the following var obj?
//VIEW FILE for private networking stream between admin and clientele:
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<html>
<title>Chat</title>
<head>
<?php echo smiley_js(); ?>
</head>
<body>
<?php echo form_open('controller/function');?>
Reload chat<?php echo form_submit('reload','reload chat');?>
<?php echo form_close();?>
<?php if(isset($user_query)): foreach($user_query->result() as $row):?>
<p>Created at: <?php echo $row->created_at; ?> </p>
<p>Updated at: <?php echo $row->updated_at; ?> </p>
<p><label for="update"> <?php echo $username_sess.' said'?>:<span class="optional"></span></label>
<textarea name="update" id="update" rows="7" cols="30"><?php echo $row->clt_rep_stream ?></textarea>
<?php echo form_open('controller/function');?>
<?php echo form_hidden('user_id',$row->user_id) ?>
<p><label for="adm_update">reply to client:<span class="optional"></span></label>
<textarea name="adm_update" id="adm_update" rows="7" cols="30"> </textarea>
<?php echo form_error('adm_update'); ?>
</p>
<?php echo form_submit('submit','reply');?>
<?php echo form_close();?>
<?php echo form_open('controller/function'); ?>
<?php echo form_hidden('user_id',$row->user_id) ?>
<p>Replied at: <?php echo $row->adm_created_at; ?> </p>
<p>Updated at: <?php echo $row->adm_updated_at; ?> </p>
<p><label for="reupdate"> <?php echo $username_adm_sess.' replied:'?><span class="optional"></span></label>
<textarea name="reupdate" id="reupdate" rows="7" cols="30"><?php echo $row->adm_rep_stream ?> </textarea>
<p>
<?php echo form_submit( 'submit', 'update reply'); ?>
</p>
<?php echo form_close(); ?>
<?php endforeach; ?>
<?php endif; ?>
<script>
function autoRefresh(refreshPeriod) {
var obj = document.getElementById("create");
var obj_two = document.getElementById("update");
var obj_three = document.getElementById("delete");
var obj_four = document.getElementById("reload");
function refreshIfSafe() {
if (document.activeElement !== obj) {
window.location.reload();
} else {
setTimeout(refreshIfSafe, refreshPeriod);
}
}
setTimeout(refreshIfSafe, refreshPeriod);
}
autoRefresh(2 * 1000);
</script>
</body>
</html>
I tried the following but didn't work:
if(document.activeElement !==(obj || obj_two))
I tried the following after Brad's post which partially worked but any update or replies after the first two and the following js is rendered null and void which is really confusing:
if(document.activeElement !== obj && document.activeElement !== obj_two)