Jump to content

Recommended Posts

Works fine in other browsers I've tested so far (Chrome & Safari)  ::)

 

<script type='text/javascript'>

// TODO - this does not work if FF - other browsers are fine.
function showPaypal(paypal_value) {

	var src_value = paypal_value;


	var target = 'paypal_details';
	var settingvalue = document.getElementById('showpal_value').value;

	if(src_value == 'on') {
		document.getElementById('paypal_details').style.visibility = 'visible';
	} else {
		document.getElementById('paypal_details').style.visibility = 'hidden';
	}

	alert(document.getElementById('paypal_details').style.visibility);

}
</script>

 

The html bit is this

 

<input type="checkbox" name="showpal" id="showpal_value" onclick="showPaypal(value);" <?php if($agent_show == 'checked') { echo "checked=\"checked\" "; } ?>/>
<?php echo $agent_show . "<br />"; ?>

<div id="paypal_details">
<?php echo $paypal_code; ?>
</div>

 

I can't see anything technically wrong, and it's from a tutorial (modified to suit my needs).  Sorry for all the JS questions, but it's not my strongest point, though I am learning quicky!  :D

Sorry, I was a bit vague  ::)

 

Basically, in Firefox, the element paypal_details will show on a onclick event, but not hide when the element is clicked again.  This works in other browsers, but not FF.  I have firebug installed, but it doesn't show any errors when it fails to hide the div.

 

As for value, I'm sure that can be removed.  It wasn't working before I added that, and still didn't work afterwards,  so I don't think thats the issue.

 

Thanks

As Omirion pointed out, value doesn't appear to be a valid value. The target and settingvalue definitions appear to be redundant code. Plus would it not be better to hide the element with display:none?

 

Personally I'd rewrite your function, seems a little dodgey to me:

 

   function togglePaypal(obj) {
      var ppd = document.getElementById('paypal_details');
      if (ppd.style.display == 'none') {
         ppd.style.display = 'block';
      } else {
         ppd.style.display = 'none';
      }
   }

 

 

Then just call it with:

 

onclick="togglePaypal(this);"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.