PDA

View Full Version : Javascript to prevent edit of textbox??



mikebyrne
Mar 18th, 2008, 11:56 AM
Is it possible to use Javascript to prevent a textbox being edited on my edit.php page?



<div class="editRightForm">
<input type="text" class="itemEditForm02" name="ProductNo" value="<?php echo $row['ProductNo'];?>" />
</div>


The complete code for my page is:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>e-commerce admin page sample |item</title>
<link href="../Admin_files/admin.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript" src="../Admin_files/wrapper.js"></script>
</head>
<body>
<div id="Box">
<div id="logoBox"><a href="http://www.btrax.com/" target="_blank"><img src="../Admin_files/logo.gif" width="51" height="125" border="0" /></a></div>
<div id="contentBox">
<form>

<!-- logo start -->
<div id="container">
<div class="padTop28">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
</div>

<div class="clr">
<!-- -->
</div>
<!-- logo finish -->
<!-- menu start -->
<div id="container">
<div id="menu1">
<div id="menu_off"><!-- --></div>
<div id="menu_text_off"><a href="../admin_files/start.php" class="black">Order</a></div>
<div id="menu_space1"><!-- --></div>
<div id="menu_off"><!-- --></div>

<div id="menu_text_off"><a href="../admin_files/sales.php" class="black">Sales</a></div>
<div id="menu_space1"><!-- --></div>
<div id="menu_on"><!-- --></div>
<div id="menu_text_on"><a href="../admin_files/list.php" class="black_on">Edit item</a></div>
<div id="menu_space1"><!-- --></div>
<div id="menu_off"><!-- --></div>
<div id="menu_text_off"><a href="../shipping/current.php" class="black">Postage fee</a></div>
<div id="menu_space1"><!-- --></div>
<div id="menu_off"><!-- --></div>
<div id="menu_text_off"><a href="../shipping/adminreg.php" class="black">Add User</a></div>
<div id="menu_space1"><!-- --></div>
<div id="menu_off"><!-- --></div>
<div id="menu_text_off"><a href="../shipping/current.php" class="black">Add Product</a></div>
<div id="menu_space1"><!-- --></div>
</div>
<div class="clr"><!-- --></div> <div class="clr"><!-- --></div>
<div class="padTop5"><!-- --></div>
<div class="clr"><!-- --></div>

<div id="dotted"><!-- --></div>
<div class="clr"><!-- --></div>
<div class="padTop5"><!-- --></div>
<div class="clr"><!-- --></div>
<div id="menu2">
<div id="menu_hide"><!-- --></div>
<div id="menu_text_off">&nbsp;</div>
<div id="menu_space1"><!-- --></div>
<div class="clr"><!-- --></div>
<!-- -->


<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>
<!-- Double Space undernath CD -->
<div class="clr"><!-- --></div> <div class="clr"><!-- --></div>
<div class="padTop5"><!-- --></div>
<div class="clr"><!-- --></div>
<div class="clr"><!-- --></div> <div class="clr"><!-- --></div>
<div class="padTop5"><!-- --></div>
<div class="clr"><!-- --></div>
<!-- menu finish -->
<!-- top start -->
<div id="container">
<div id="line">
<!-- -->

</div>
</div>
<div class="clr">
<!-- -->
</div>
<div id="containerBg1">
<div class="padTop15">
<!-- -->
</div>

<div class="clr">
<!-- -->
</div>
<div id="titleText">EDIT ITEM</div>
<div class="clr">
<!-- -->
</div>
<div class="padTop15">

<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>

<!-- top finish -->
<!-- data title start -->
<div id="containerBg2">
<div class="padTop2">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>

<div class="titleBox">
<table width="850" border="0" cellspacing="0" cellpadding="0">
<tr align="left">
<td width="33">&nbsp;</td>
<td width="290" align="left">IMAGE</td>
<td width="527">DETAIL</td>
</tr>
</table>

</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>
<!-- data title finish -->

<!-- 1px space start -->
<div id="containerBg1">
<div class="padTop1">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
</div>

<div class="clr">
<!-- -->
</div>
<!-- 1px space finish -->
<!-- data top start -->
<div id="containerBg3">
<div class="padTop1">
<!-- -->
</div>

<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>
<!-- data top finish -->
<!-- data content start -->
<?php
// let's get some data
$name = $_POST["something"];
include('adminconnect.php');

$query = "SELECT * FROM Product WHERE ProductNo='$name' ";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
// loop through and display
?>



<div id="containerBg4">
<div class="padTop15">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<div class="padTop1">
<!-- data Left start -->

<div class="editLeft">
<!-- picture1 start -->
<div class="editLeftBox">PICTURE 1:</div>
<div class="clr">
<!-- -->
</div>
<div class="padTop5">
<!-- -->

</div>
<div class="clr">
<!-- -->
</div>
<div class="editLeftBox"><img src="<?php echo $row['Image'];?>" alt="pic1" width="150" height="200" /></div>
<div class="clr">
<!-- -->
</div>
<div class="padTop5">

<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<div class="editLeftBox">
<input type="file" name="uploadfile" class="newsUpFile">
</div>
<div class="clr">

<!-- -->
</div>
<!-- picture1 finish -->
<div class="padTop50">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>

<!-- picture2 start -->
<div class="editLeftBox">PICTURE 2:</div>
<div class="clr">
<!-- -->
</div>
<div class="padTop5">
<!-- -->
</div>

<div class="clr">
<!-- -->
</div>
<div class="editLeftBox"><img src="<?php echo $row['Image2'];?>" alt="pic1" width="150" height="200" /></div>
<div class="clr">
<!-- -->
</div>
<div class="padTop5">
<!-- -->

</div>
<div class="clr">
<!-- -->
</div>
<div class="editLeftBox">
<input type="file" name="uploadfile" class="newsUpFile">
</div>
<div class="clr">
<!-- -->

</div>
<!-- picture2 finish -->
</div>
<!-- data Left finish -->
<!-- data Right start -->
<div class="editRight">
<!-- dat start -->
<div class="editRightBox">
<div class="editRightText">Product No:</div>

<div class="editRightForm">
<input type="text" class="itemEditForm02" name="ProductNo" value="<?php echo $row['ProductNo'];?>" />
</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->

</div>
<!-- data finish -->
<div class="padTop3">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<!-- dat start -->

<div class="editRightBox">
<div class="editRightText">Product Name:</div>
<div class="editRightForm">
<input name="0" type="text" class="itemEditForm02" name="something" value="<?php echo $row['ProductName'];?>" />
</div>
<div class="clr">
<!-- -->
</div>

</div>
<div class="clr">
<!-- -->
</div>
<!-- data finish -->
<div class="padTop3">
<!-- -->
</div>
<div class="clr">

<!-- -->
</div>
<!-- dat start -->
<div class="editRightBox">
<div class="editRightText">Description:</div>
<div class="editRightForm">
<textarea type="text" class="itemEditForm03" name="something" ><?php echo $row['Description'];?></textarea>
</div>

<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>
<!-- data finish -->
<div class="padTop3">

<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<!-- dat start -->
<div class="editRightBox">
<div class="editRightText">Remarks:</div>

<div class="editRightForm">
<input type="text" class="itemEditForm02" name="0" value="" />
</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->

</div>
<!-- data finish -->
<div class="padTop3">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<!-- dat start -->

<div class="editRightBox">
<div class="editRightText">Price:</div>
<div class="editRightForm">
<div class="editItemPrice1"></div>
<div class="editItemPrice2">
<input type="text" class="itemEditForm04" name="0" value="<?php echo $row['Price'];?>" />
</div>
<div class="clr">

<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>

<!-- data finish -->
<div class="padTop3">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<!-- dat start -->
<div class="editRightBox">

<div class="editRightText">Sale:</div>
<div class="editRightForm">
<div class="editRadioLink1">
<input name="link" type="radio" value="yes" />
</div>
<div class="editRadioLink2">Yes</div>
<div class="editRadioLink3">
<input name="link" type="radio" value="no" checked="checked" />

</div>
<div class="editRadioLink4">No&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;sale price: </div>
<div class="editRadioLink5">
<input type="text" class="newsEditForm02" name="0" value="0" />
</div>
<div class="clr">
<!-- -->

</div>
</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>

<!-- data finish -->
<div class="padTop3">

<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<!-- dat start -->
<div class="editRightBox">

<div class="editRightText">Display:</div>
<div class="editRightForm">
<div class="editRadio1">
<input name="display" type="radio" value="yes" checked="checked" />
</div>
<div class="editRadio2">show</div>
<div class="editRadio3">
<input name="display" type="radio" value="no" />

</div>
<div class="editRadio4">hide</div>
</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">

<!-- -->
</div>
<!-- data finish -->
<div class="padTop75">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>



</div>
<!-- data Right finish -->
</div>
<div class="clr">
<!-- -->
</div>
<div class="padTop11">
<!-- -->
</div>

<div class="clr">
<!-- -->
</div>
<div id="dottedIn">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>

<!-- data finish -->
<!-- btn start -->
<div class="clr">
<!-- -->
</div>
<div class="padTop16">
<!-- -->
</div>
<div class="clr">

<!-- -->
</div>
<div id="btn">
<div id="btnL"><img src="../Admin_files/btn_update.gif" width="73" height="23" /></div>
<div id="btnSpace">
<!-- -->
</div>
<div id="btnR"><img src="../Admin_files/btn_clear.gif" width="73" height="23" /></div>
<div class="clr">

<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>
<div class="padTop16">
<!-- -->
</div>

<div class="clr">
<!-- -->
</div>
<!-- btn finish -->
</div>
<div class="clr">
<!-- -->
</div>
<?php
}
?>
<!-- data content finish -->

<!-- data btm start -->
<div id="containerBg3">
<div class="padTop1">
<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
</div>

<div class="clr">
<!-- -->
</div>
<!-- data btm finish -->

</form>
</div>
<!-- btm start -->
<div id="containerBg1">
<div class="padTop15">

<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>

<div id="container">
<div id="line">
<!-- -->
</div>
</div>
<div class="clr">
<!-- -->
</div>
<div class="padTop16">

<!-- -->
</div>
<div class="clr">
<!-- -->
</div>
<!-- btm finish -->
</div>
</body>
</html>

Kor
Mar 18th, 2008, 11:58 AM
make it readonly:


<input type="text" class="itemEditForm02" name="ProductNo" value="<?php echo $row['ProductNo'];?>" readonly="readonly" />

mikebyrne
Mar 18th, 2008, 01:26 PM
Thats great! Thanks