Hi IceKat

If javascript is required for the link - then write/append it to the page using javascript - then if javascript is being used - no link


On 22/05/2008, at 1:31 PM, IceKat wrote:


Thanks to those who have replied so far. I'm still a bit lost because this has gotten a bit more complicated so I'll explain a bit.

I have a page which lists records in a mysql database. They each have varying options including delete. They are printed with a php loop. The table of records is in a form and the delete button has in fact become a input type=image which posts some data back to the page with a javascript return confirm. The posted data is then excecuted. The php and mysql is fine but the javascript is doing the confirming which means that if it's turned off then there is no confirmation of the delete. This is the reason why I am trying to put in a regular image with a link to another page which only appears if javascript is disabled.

I know this isn't a JavaScript help page but I'm hoping that someone will understand my babbling because I'm having trouble getting this to do what I need and validate my page at the same time. The first solution posted by Michael seemed good until I realised it was actually an input type=image that I needed (sorry about that). The solution below seems to do what I need but the complexity of the javascript makes me feel cold.

Can anyone either mail me directly to save clogging up this mailing list or point me to a place where I can learn what I need? Does anyone know a good javascript forum?

Many Thanks,

David Dorward wrote:

Three issues:

1: A start tag starts an element, an end tag ends an element, and elements must be contained entirely within other elements.

2: noscript is a very poor means of handling the 'no js case', it doesn't cope with 'JavaScript supported, but not the functions you are calling'

3: Links make GET requests, and GET requests shouldn't do anything significant to the server (like deleting files). People have run into problems with precaching proxy servers following all the links to get the content available for users and deleting lots of files as they go. For changes to the server, use POST.

I would do something like this:

<form method="POST" action="a_link.html" class="delete_file">
   <input name="delete" type="image"
          src="pics/delete.gif" alt="Delete File">

And then:

<script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/yahoo-dom-event/yahoo-dom-event.js "></script>
<script type="text/javascript">
 function deleteFiles(e, obj) {
YAHOO.util.Event.preventDefault(e); // Don't submit the form normally
   // And then whatever else you want your JS to do
var elements = YAHOO.util.Dom.getElementsByClassName('delete_file', 'form');
 YAHOO.util.Event.addListener(elements, "submit", deleteFiles);

YUI documentation is available from http://developer.yahoo.com/yui/

List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm

List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm

Reply via email to