echo ("<tr bgcolor='B0C4DE'>"); 

$value=$row['idbook_code'];
$author=$row['b_author'];
$book=$row['b_name'];
		echo ('ISBN :     '.$row['idbook_code'].'<br/>');
		echo ('Title :    '.$row['b_name'].'<br/>');
		echo ('Author :   '.$row['b_author'].'<br/>');
		echo ('Books Available  :  '.$row['b_avail'].'<br/>');
	
		if($row['b_avail']>0)
		{
				if (!$_SESSION["valid_user"])
        {
        // User not logged in, redirect to login page
		echo("Available".'<br/>');
		}else
		{
       echo("<input type='hidden' name='idbook' value='$value'>");
	   echo("<input type='hidden' name='author' value='$author'>");
	   echo("<input type='hidden' name='book' value='$book'>");
?>
	   
<input type='submit' name='submitbutton' value='Add to Cart' onsubmit='submitPressed()' ><br/>
<?php
		}
		
		}else
	
		echo("No stock of book".'<br/>');
		
		echo("</tr>".'<br/>');
		echo("<tr>");echo("==============");echo("</tr>".'<br/>');
		
		?>

how can i disable a button is clicked

Recommended Answers

All 13 Replies

Member Avatar for diafol

Use javascript

Use onclick attribute or an event handler.

Use javascript

Use onclick attribute or an event handler.

can you give me an idea

Member Avatar for diafol

OK, I assume you're submitting via ajax? If not you don't need to disable do you?


THis is the only form button/submit that you have:

<input type='submit' name='submitbutton' value='Add to Cart' onsubmit='submitPressed()' ><br/>

Which buttons do you need to disable? Which event causes disable. When should they/it be enabled again?

I need more info.

onclick="this.disabled=true;" on whatever button you want disabled

what if the button is dynamic??? can you tell me what should i do???

OK, I assume you're submitting via ajax? If not you don't need to disable do you?


THis is the only form button/submit that you have:

<input type='submit' name='submitbutton' value='Add to Cart' onsubmit='submitPressed()' ><br/>

Which buttons do you need to disable? Which event causes disable. When should they/it be enabled again?

I need more info.

button is disable when click as you can see the button is echo equal to item that been search so the button will show 5 or more button my problem is i need to disable button when clicked

Member Avatar for diafol

If the button is produced by php - no problem as it is created before js gets a grip on anything.Have you tried it? Look, give things a go, and come back with some code (new stuff).

When you retrieve b_avail and create the button, set the rules the if the book is unavailable, button is disabled.

When you retrieve b_avail and create the button, set the rules the if the book is unavailable, button is disabled.

i know that... the problem is to avoid multiple sumbitting

for that I thought wcordio had provided the solution?

try:

<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>
<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>
<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>
<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>

for that I thought wcordio had provided the solution?

try:

<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>
<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>
<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>
<input type='submit' name='submitbutton' value='Add to Cart' onclick='this.disabled=true'><br/>

the code is working when i change the submit to button but when i click the next page the disabled button is back to enable how can i get that work??? that even i change page it's still disabled

back to my first reply, when you're at the new page, you should disable those buttons when the query for b_avail is false.

back to my first reply, when you're at the new page, you should disable those buttons when the query for b_avail is false.

i dont get your idea sir can you tell me how to do it ???

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.