Hello, I'm sorry I bumped old and solved article, so I'm opening new.

The problem is here:

http://www.daniweb.com/web-development/php/threads/419063/updating-single-record-in-mysql-table-with-php-using-toggle-button

This works fine, except that I have to click button two times the first time to change the status. later itr works fine. Anyone knows how to fix that?

Thank You!

Ok, so I found the problem.

When clicked first time, here:

var vars = 'id='+id+'&value='+obj.value;

obj.value is not set, and that's why I have to click twice. Anyone knows hot to make it work?
Thanks.

Figured out, the problem is in lines:

'<input type="image" onclick="updateToggle(this, ' . $row["sifra"] . ');" src="status-toggle_enabled.jpg" border="0" name="enabled" value="0"/>';

just had to invert "value" :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.