Welcome Guest, Not a member yet? Register   Sign In
My code works in Mozilla but not in IE - what's the problem
#1

[eluser]cinewbie81[/eluser]
Hi all,

I have a 'Customer' Controller class as following:

Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Customer extends Globalsetting {
    
    function Customer()
    {    
        parent::Globalsetting();
        $this->load->helper(array('listing', 'url','form'));
        $this->load->library('table');
        $this->load->model('dbmodel', 'sql', TRUE);
        $this->load->plugin('pagination');
        $this->load->library('pagination');
        $this->load->database();
    }

    function listing()
    {
        $this->GenerateCustomerListing(); // Will generate customer listing
        $this->data['ShowTKey'] = __YES__;
        $this->load->view('customer_view', $this->data);
    }

    function action()
    {
        if ($this->input->post('add')) {
            echo 'Add';
        } else if ($this->input->post('edit')){
            echo 'Edit';
        } else if ($this->input->post('delete')){
            echo 'Delete';
        }            
    }
}
?>



and the customer view form as following:
Code:
<?php
    $this->load->view("view_header");
    echo form_open('customer/action');
?>

    <div id="menu_icon">            
        &lt;input type="image" name="add" src="&lt;?php echo base_url();?&gt;images/add.gif" value="Add" alt="Add" title="Add Customer" height="50px" width="42"&gt;

        &lt;input type="image" name="edit" src="&lt;?php echo base_url();?&gt;images/edit.gif" value="Edit" alt="Edit" title="Edit Customer" height="50px" width="42"&gt;

        &lt;input type="image" name="delete" src="&lt;?php echo base_url();?&gt;images/delete.gif" value="Delete" alt="Delete" title="Delete Customer" height="50px" width="42"&gt;    
    </div>

    &lt;?php echo form_close();?&gt;

&lt;?php
    $this->load->view("view_footer");
?&gt;

When i click at the button 'Add' from cutomer_view, it will go to 'action' function, then will echo the message 'Add'.
It is working in mozilla firefox, but in IE6 and IE7 it doesnt echo me anything. What is the problem anyone ? I've been finding the solution for quite a while but still no avail Sad
#2

[eluser]cinewbie81[/eluser]
In case anyone want to know what's inside view_header and view_footer, here it is:

view_header
Code:
&lt;?php if (!isset($ajax)){ $ajax = 0;}
    if ($ajax){ return; } echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'; ?&gt;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
        &lt;title&gt;&lt;?php echo 'TextAlerter' ?&gt;&lt;/title&gt;
        &lt;meta name="copyright" content="" /&gt;
        &lt;meta name="keywords" content="" /&gt;
        &lt;meta name="description" content="" /&gt;
        &lt;meta http-equiv="content-type" content="text/html;charset=UTF-8" /&gt;
        &lt;meta http-equiv="content-type" content="application/xhtml+xml;charset=UTF-8" /&gt;
        &lt;meta http-equiv="content-style-type" content="text/css" /&gt;
        &lt;link href="&lt;?php echo base_url();?&gt;css/general.css" rel="StyleSheet" type="text/css" /&gt;
        
&lt;/head&gt;
&lt;body&gt;
view_footer
Code:
&lt;?php if (!isset($ajax)){ $ajax = 0;} if ($ajax) { return; } ?&gt;


    <div id="border-bottom">
        <div>
            <div>
                <div>
                    (c) 2007 <a target="_blank" href="http://www.mysite.com">My Company</a> . All rights reserved.
                </div>
            </div>
        </div>
    </div>


&lt;/body&gt;
&lt;/html&gt;
#3

[eluser]Alex007[/eluser]
I ran into the exact same problem.

The thing is, IE does NOT pass the "value" when input type=image. Mozilla does.

To test, change it to a button, everything will work.

I haven't looked into a solution yet, but I guess I'll have to use javascript with a normal image. Clicking on the image will set a value for a hidden field, then submit the form. It sucks, but I'm still trying to find better ways.

That, or use normal buttons, and style them with CSS, which I haven't tried.
#4

[eluser]cinewbie81[/eluser]
so is that mean i have to change all my image to button ? ARGHHH that's gonna cause me quite some times to change my WHOLE module ..

Anyway, cheers alex..
You have just save my time for figuring out the problem .. thanks alot..

and if anyone here have any idea how to solve it, feels free to post a reply here .. thanks again in advance
#5

[eluser]xwero[/eluser]
you can use name for input type image to pass a value. The only caveat is that the name is prostfixed with _x and/or _y because browsers pass the coordinates of the click that way.
#6

[eluser]Alex007[/eluser]
You can style submit buttons with CSS:

http://www.ampsoft.net/webdesign-l/image-button.html
#7

[eluser]cinewbie81[/eluser]
[quote author="xwero" date="1195861180"]you can use name for input type image to pass a value. The only caveat is that the name is prostfixed with _x and/or _y because browsers pass the coordinates of the click that way.[/quote]

Hi, can you please elaborate with code ? I dont quite understand what do you mean .. thanks
#8

[eluser]xwero[/eluser]
I didn't take a good look at your code but i saw now you have a name for you button so you could get your post as follows
Code:
if ($this->input->post('add_y')) {
            echo 'Add';
        } else if ($this->input->post('edit_y')){
            echo 'Edit';
        } else if ($this->input->post('delete_y')){
            echo 'Delete';
        }
Now you would have some results. You could make one button and separate it by the _x coordinates.
#9

[eluser]cinewbie81[/eluser]
Now it's works ..
Didnt know that you have to put a postfix 'x' or 'y' when u want to pass a value from input image type .. Thanks
#10

[eluser]Seppo[/eluser]
You should check it against false, checking also the type. I believe some times it is submitted with a 0 value (not sure when, may be when pressing enter button or when there are multiple submit images)

Code:
if ($this->input->post('add_y') !== false) {
            echo 'Add';
        } else if ($this->input->post('edit_y') !== false){
            echo 'Edit';
        } else if ($this->input->post('delete_y') !== false){
            echo 'Delete';
        }




Theme © iAndrew 2016 - Forum software by © MyBB