Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: PHP/JS Help

  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP/JS Help

    Hi,

    I'm trying to make a code where I can highlight 1 or 2 using Javascript, and when I submit the form the php will know which code is highlighted and then I can use it later on in my code.

    Code:
    <script type="text/javascript"><!--
    function checkBoxClick($) {
    	$.className = 'boxSelected'; for(var i = 0, _ = $.id.split('_'); 	i <= 4; i++	) {if(_[1] != i) {try {document.getElementById(_[0] + '_' + i).className = 'box';} catch(__) { break; }}}window.document.forms[0][_[0]].value = _[1];
    }
    //--></script>
    
    <span class="boxSelected" onclick="checkBoxClick(this);" id="blaah_1">1</span><br />
    <span class="box" onclick="checkBoxClick(this);" id="blaah_2">2</span>
    I'm new here so I don't really know if my explanation is good enough.

    But thanks in advance for anybodies help as I've been on this for 2 hours

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    I think you might have to pass the Javascript action - or whatever it's called - to a cookie and then read the cookie with PHP, this will require a page reload. PHP variables to Javascript variables is easy, but Javascript variables to PHP variables is tricky and the only way I know is through cookies.



    ------------
    Leonard Whistler


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •