Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

issue with Greying out field in javascript

Status
Not open for further replies.

Steel811

Programmer
Jan 2, 2008
26
0
0
US
Hello, I have a small snippet of code that isn't functioning the way I expected it to, after migrating the website from a Linux box to a windows server. I previously did post this on the PHP forum, but they feel this is a javascript issue, so I'm posting here. Below is that snippet of code:
<?php
...code that is working ok...
for($i = 0; $i <= $numberOfDays; $i++){

$thisDiv = microtime();
?>


<!-- BEGIN ARRAY ITEMS-->
<div class="boundingBox" id="bb<?= $thisDiv ?>">
<!-- -->
<label for="hotelID">Sleeping Room</label>
<input type="hidden" name="hotelID[]" value="hotelroom" />
<!-- -->

<!-- -->
<label for="date">Day and Date:</label>
<input type="text" name="stayDate[]" value=<?php echo $getNextDay ?> />
<!-- -->

<!-- -->
<label for="date">number of Rooms:</label>
<input type="text" name="numberOfRooms[]" value="1" />
<!-- -->
<a href="javascript:greyOut('bb<?= $thisDiv ?>')">X</a>
<!-- END ARRAY ITEMS -->
</div>

<?php
$dateItem = explode("/", $getNextDay);

$getNextDay = Date_Calc::nextDay($dateItem[1],$dateItem[0],$dateItem[2],'%m/%d/%Y');
}

?>

The line in particular that is giving me trouble is the <a href="javascript:greyOut('bb<?= $thisDiv ?>')">X</a> line. This is supposed to remove or greyOut the box by clicking on the X, but what it does is when I click on the first one, it deletes it, but when I click on the second one, the first one re-appears. It's quite odd. Does anyone know what may be causing this?

Thanks,
Sheel Shah
 
No idea, we could help you better if you posted client side code instead of a mix of php, html and javascript. Also include your functions. I have no idea what your greyOut function looks like or what it does.
 
you've not posted an Javascript for this Javascript problem.


But from what you describe it seems over engineered.

You just need to set the disabled or readonly attribute of the field in question. You can toggle this with a small Javascript function that attaches the relevant event handler to your 'x' button. I can recommend the use of a Framework such as jQuery for making this very simple to do.



--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top