Welcome Guest, Not a member yet? Register   Sign In
Browser issue with form submit
#1

[eluser]bhakti.thakkar[/eluser]
hi all,
i have made a form and it works fine in IE. but the submit fails in opera / firefox. below is my code. it doesn't give me any error. The submit button gets clicked but doesnt do any thing (doesn't invoke the method in the controller)

below is my code. what should be modified?
Code:
<?
$attributes = array('id' => 'mainform' , 'name' => 'mainform');
echo form_open('clientprofile/saveContactDetails/' , $attributes); ?>
<input type="hidden" name="Contact_ID" value="<?=$querycontacts->Contact_ID?>">
        <tr>
            <td class="tdheader">Name </td>
            <td class="datatd">&lt;?=$this->site_sentry->GetContactName($querycontacts->Contact_ID)?&gt;</td>
        </tr>

        <tr>
            <td class="tdheader">Telephone </td>
            <td class="datatd">&lt;input type="text" class="txtbox" name="Telephone_VC" value="&lt;?=$querycontacts-&gt;Telephone_VC?&gt;"> Short &lt;input type="text" class="smtxtbox" name="TelephoneShort_VC" value="&lt;?=$querycontacts-&gt;TelephoneShort_VC?&gt;"> </td>
        </tr>
            <tr>
            <td class="tdheader">Fax</td>
            <td class="datatd">&lt;input type="text" class="txtbox" name="Fax_VC" value="&lt;?=$querycontacts-&gt;Fax_VC?&gt;"></td>
        </tr>
        <tr>
            <td class="tdheader">Mobile</td>
            <td class="datatd">&lt;input type="text" class="txtbox" name="Mobile_VC" value="&lt;?=$querycontacts-&gt;Mobile_VC?&gt;"> Short &lt;input type="text" class="smtxtbox" name="MobileShort_VC" value="&lt;?=$querycontacts-&gt;MobileShort_VC?&gt;"> </td>
        </tr>
        <tr>
            <td class="tdheader">E-mail</td>
            <td class="datatd">&lt;input type="text" class="txtbox" name="EMail_VC" value="&lt;?=$querycontacts-&gt;EMail_VC?&gt;"></td>
        </tr>
        <tr>
            <td colspan=2> &lt;input type="submit" name="save" value="Save" style="cursor:hand"&gt;
            &nbsp;&lt;input type="button" value="Cancel" style="cursor:hand" name="Cancel"&gt;    
        </tr>
&lt;/form&gt;

Please help
Thanks
#2

[eluser]trice22[/eluser]
What Doctype are your using?
—trice
#3

[eluser]bhakti.thakkar[/eluser]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
#4

[eluser]trice22[/eluser]
You could try a strict doctype:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

And then close all the open tags (you've some inconsistencies there). Especially input tags:
Code:
&lt;input name="myname" type="button" value="click me" /&gt;
but also table cells.
—Then see what happens.

I have no clue if that's gonna help you, but I couldn't see anything else in your code yet…
—trice
#5

[eluser]bhakti.thakkar[/eluser]
[quote author="trice22" date="1233149085"]You could try a strict doctype:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

And then close all the open tags (you've some inconsistencies there). Especially input tags:
Code:
&lt;input name="myname" type="button" value="click me" /&gt;
but also table cells.
—Then see what happens.

I have no clue if that's gonna help you, but I couldn't see anything else in your code yet…
—trice[/quote]

ok let me try and see the result ...back in few minutes to update you
Thanks
#6

[eluser]bhakti.thakkar[/eluser]
nothing happens. i changed the doctype to what you said and still it doesnt work!!!
#7

[eluser]darkhouse[/eluser]
Maybe it's because your &lt;form&gt; ends up being between <table> and <tr>, which is not allowed. Your form should be setup like this

Code:
&lt;?php echo form_open('foo/bar', $attributes); ?&gt;
<table>
<tr>....</tr>
</table>
&lt;/form&gt;

I think you really need to work on your HTML structure. I rarely use tables anymore, only for tabular data (which is their intended purpose). For forms I use fieldset, legend and label and you are able to style your forms better, plus they're more accessible.

I use the xhtml 1.0 strict doctype, don't use 1.1 yet as it's not fully supported. And make use of the [url="http://validator.w3.org/"]w3 validator[/url], it will identify html issues like this.
#8

[eluser]bhakti.thakkar[/eluser]
Thanks a lot!!!
never in my wildest dreams i had imagined this could be the problem. i shifted the form above the table and the things are working perfect.
but still i dont understand why this should hamper the functionality of the form submit button.
#9

[eluser]darkhouse[/eluser]
What happens is when you put something between <table> and <tr> (or anywhere you're not supposed to put elements) it actually renders before the table, so your code was actually being interpreted like this

Code:
&lt;form&gt;&lt;/form>
<table>
<tr>...</tr>
<tr><td>&lt;input type="submit" /&gt;&lt;/td></tr>
</table>

So you see, your inputs were not actually in the form, and therefore the submit button did not know what to submit. It's actually the fact that IE and other browsers are so loose that they will still function if you use malformed html markup, and that throws people off. People often don't pay attention to html standards or valid markup, and it's the root of a lot of problems.

So, like I said, pay careful attention to your html structure, follow the standards, they're there for a reason. And make use of the validator, it's your friend.

Happy Coding.
#10

[eluser]bhakti.thakkar[/eluser]
That was something i dint knew.
Again Million Million Thanks to both for you for updating me on this. Now many of my things are working on other browsers the way it should. I will now be careful on these issues.
Hope it also helps others too who didn't knew about this!!!




Theme © iAndrew 2016 - Forum software by © MyBB