View Full Version : PHP/JS Help

01-18-2010, 08:37 PM

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.

<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];

<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 :eek:

Len Whistler
01-18-2010, 10:10 PM
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.