Jump to content

Form works in IE 9 but not Firefox or other IE's


ebolt007

Recommended Posts

Ok, so I have a REALLY strange problem. So I am trying to delete an array of checkboxes with an input delete piece and I have used a bit of a tutorial on the deletion part.

But, my form works fine in IE9 when I do this and doesn't work in firefox when I have it inside a <form> tag.

 
<form name="deletecheckbox" method="post" action=""> 
                        <input name="delete" class="delete_button" type="submit" id="delete" value="Delete" /> 

//some checkboxes pulled in dynamically thru ajax inside a loop and I won't put the whole looping code just what the checkbox looks like
<input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$ID\">
<?
           
                  $contact_query = "SELECT ID FROM Contacts ORDER BY ID ASC";
                  $contact_query_result = mysql_query($contact_query);
                  $count=mysql_num_rows($contact_query_result); 
                if($delete){
                for($i=0;$i<$count;$i++){
                $del_id = $checkbox[$i];  
                $sql = "DELETE FROM Contacts WHERE ID='$del_id'";
                $result = mysql_query($sql);
                }
                }
                ?>
</form>

 

Now, if I do the same thing without the form part, it works in Firefox but not in IE

 
<input name="delete" class="delete_button" type="submit" id="delete" value="Delete" /> 

//some checkboxes pulled in dynamically thru ajax inside a loop and I won't put the whole looping code just what the checkbox looks like
<input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$ID\">
<?
           
                  $contact_query = "SELECT ID FROM Contacts ORDER BY ID ASC";
                  $contact_query_result = mysql_query($contact_query);
                  $count=mysql_num_rows($contact_query_result); 
                if($delete){
                for($i=0;$i<$count;$i++){
                $del_id = $checkbox[$i];  
                $sql = "DELETE FROM Contacts WHERE ID='$del_id'";
                $result = mysql_query($sql);
                }
                }
                ?>

 

Anyone know what's goin on here? I'm lost.

 

Link to comment
Share on other sites

Well, one thing I learned early on is if something is working in some browsers (and not others) the issue is never your PHP code.  You can drive yourself THINKING that it is, but it's not...the issue you're having is how the browsers are handling malformed HTML, and that's solved easiest by validating your html!

 

At first glace, the thing that sticks out is

 

<input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$ID\">

 

If that is how they are being sent to the browser, it's going to choke . I would do it like this

 

<?php foreach ($data as $row): ?>
     <input name="checkbox[]" type="checkbox" value="<?= $row['ID'] ?>">
<?php endforeach; ?>

 

Make sure you don't have escaped quotes \" being sent to the browser, and ID's with html have to be UNIQUE.  id="checkbox[]" means nothing to the browser, it's just going to start choking

 

 

Link to comment
Share on other sites

It's weird, I hate php short tags by themselves - but I love using them in views and such.

 

<?= $var ?> seems a lot prettier to me than <?php echo $var ?> (while in the context of a view)

 

What drives me most insane tho, is when people echo out long strings of html inside php.  Seems to be the most error prone way of doing things!

Link to comment
Share on other sites

It's weird, I hate php short tags by themselves - but I love using them in views and such.

<?= $var ?> seems a lot prettier to me than <?php echo $var ?> (while in the context of a view)

 

I agree, and I wish it was possible to do

<?php= $var ?>

Then we could all be happy. It's still shorter but won't cause the same problems as short tags.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.