Quote Originally Posted by Tantirx View Post
Rewriting the logic is completely alien to me

Like I mentioned before my thing is HTML, XHTML, CSS ...javascript and php are like Chinese to me. I can implement scripts (and I have done so hundreds of times with pre-made scripts). But trying to implement them into a complex language like php is completely foreign.
Fine.
Use the corrected code I posted for approach #1, and live with the consequences of using javascript to accomplish what you're after.