mmarif4u Posted March 4, 2007 Share Posted March 4, 2007 Hi guys, I have a simple function where i check that the user enter to the user area of my site, But that user have package, there are different package in my site. When user login he see 4 buttons, i want to disable 3 buttons there, only 1 will work for that user. Ok now the problem is that make this function but it just show the disabled text on the button, Still allow the user to use all buttons. Code: $sql="select * from m_package"; $query = mysql_query($sql) or die (mysql_error()); $package = $row -> nrpackage; if ($package = $session_nrpackage){ $disabled = 'disabled = "disabled" '; } else{ $disabled = ""; } <input type="button" onclick="redirect_selection(1);" value="Selection by Set<?php echo $disabled ?>" name="btnset" class="button_assess"> Any help will be appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/ Share on other sites More sharing options...
flappy_warbucks Posted March 4, 2007 Share Posted March 4, 2007 to make a button disabled in HTML you have to set the attribute to that object. for example <input type="button" value="Click Me" disabled> this will create a button with the wording "Click Me" but it will be disabled, if you remove the disabled attribute then then button will be active. I notice on your code you have the disabled attribute within quotes in the value attribute. that will cause the attribute to be printed in the button. <input type="button" onclick="redirect_selection(1);" value="Selection by Set<?php echo $disabled ?>" name="btnset" class="button_assess"> Remove the quotes and that should work Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-199094 Share on other sites More sharing options...
mmarif4u Posted March 5, 2007 Author Share Posted March 5, 2007 Thanks flappy_warbucks. Yes u are right that i put the php block in value attribute and it wont work, So i edit the code according to ur situation but still the problem is the same. Now i make a simple code which is as follows: Code: $query = "SELECT * FROM accdtl where icnumber = 123456-00-0012"; $result = mysql_query($query) or die(mysql_error()); $ic=$row->icnumber; if ($ic == 123456-00-0012) { $disabled = 'disabled = "disabled"'; } else{ $disabled = ""; } <form> <input type="button" onClick="window.print()" value="Print" <?php echo $disabled ?> > </form> I am confused bcoz still the button works on click. Can i use javascript, but i dont want to use it. Any help will be appreciated Thanks. Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-199584 Share on other sites More sharing options...
mmarif4u Posted March 5, 2007 Author Share Posted March 5, 2007 This is now my modified page but still its not working. Any suggestions. <?php $con = mysql_connect("localhost","root","adil"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $query = "SELECT * FROM accdtl where icnumber='123456-00-0012'"; $result = mysql_query($query) or die(mysql_error()); $ic=$row->icnumber; if ($ic == '123456-00-0012') { $disabled = "disabled"; } else{ $disabled = ""; } echo "<table class='text' align=Center CELLSPACING='0'BORDERCOLOR='#007FFF' BGCOLOR='cornsilk' border='1'> <tr><th colspan=12><Font face='Verdana'size='3'>Official Receipt</th></Font> <tr> <th><Font size='1'>Customer IC</th></Font> <th><Font size='1'>Acc Code</th></Font> <th><Font size='1'>Active</th></Font> <th><Font size='1'>Date</th></Font> </tr></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo"<td>" . $row['icnumber'] . "</td></font>"; echo "<td>" . $row['acccode'] . "</td></font>"; echo "<td>" . $row['active'] . "</td></font>"; echo "<td>". $row['date'] . "</td></font>"; echo "</tr>"; } echo "</table>";mysql_close($con); echo ' <form> <input type="button" onClick="window.print()" value="Selection by Set" '.$disabled.' > </form> '; ?> Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-199724 Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 Try this: <input type='button' onClick='window.print()' value='Selection by Set' ".$disabled." > I am also wondering if you are trying to use java with this. Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-199729 Share on other sites More sharing options...
mmarif4u Posted March 5, 2007 Author Share Posted March 5, 2007 Still enable, the button is working on click. If i want to use javascript how can i will ,bocz i dont have more knowlegde about java. Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-199739 Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 I don't have much java experience but I'm sure if you do a search in the java forum on hiding objects it might turn something up. Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-199744 Share on other sites More sharing options...
mmarif4u Posted March 5, 2007 Author Share Posted March 5, 2007 Thanks. Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-199751 Share on other sites More sharing options...
mmarif4u Posted March 6, 2007 Author Share Posted March 6, 2007 Any other suggestions guys? Link to comment https://forums.phpfreaks.com/topic/41096-disabled-variable-not-work/#findComment-200499 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.