views:

277

answers:

3

My form works in firefox but not ie. I've tried using a hidden text field (fail)... I tried using an image instead of a submit button (fail)... are there any other solutions? Here is my form:

<?php

print "<table width='522' cellpadding='2' cellspacing='0' border='0'>
<tr><td valign='top' width='128'><img src='logo.gif' border='0'></td><td valign='bottom'><div style='padding-top: 10; font-family: arial; font-size: 14px;'
<form action='' method='GET'>
Search category
<select name='cat'><option value='1'"; if($cat==1){print "selected='yes'";}print">1</option>
<option value='2'"; if($cat==2){print "selected='yes'";}print">2</option>
<option value='3'"; if($cat==3){print "selected='yes'";}print">3</option>
<option value='4'"; if($cat==4){print "selected='yes'";}print">4</option>
</select>
 for <input type='text' value='$q' name='q'>
<input type='submit' value='Go' />
</form></div></td></tr>
<tr>
</table>";

print "<BR>results here";
?>
+1  A: 

Use a validator, the outputted HTML has errors in it. I expect Internet Explorer's error recovery process doesn't deal with the code about <form being broken (since you are trying to start the form element inside the start tag for another element).

David Dorward
A: 

Post your code.. Submitting a form using a button is not a server side issue (PHP) but a client side issue (HTML / Javascript).

ajl
Actually there are instances (especially with IE) whereby it can be a HTMl and PHP problem, depending on how the programmer has coded the solution.
ILMV
+3  A: 

Your div is not closed for a start.

<div style='padding-top: 10; font-family: arial; font-size: 14px;'

I've rewritten your code, use this instead ,much more efficient and easier to read / debug:

<table width='522' cellpadding='2' cellspacing='0' border='0'>
    <tr>
        <td valign='top' width='128'><img src='logo.gif' border='0'></td>
        <td valign='bottom'>
            <div style='padding-top: 10; font-family: arial; font-size: 14px;' >
                <form action='' method='GET'>
                    Search category
                    <select name='cat'>
                        <option value='1' <?php if($cat==1){echo "selected='yes'";} ?> >1</option>
                        <option value='2' <?php if($cat==2){echo "selected='yes'";} ?> >2</option>
                        <option value='3' <?php if($cat==3){echo "selected='yes'";} ?> >3</option>
                        <option value='4' <?php if($cat==4){echo "selected='yes'";} ?> >4</option>
                    </select>
                    for <input type='text' value='$q' name='q'>
                    <input type='submit' value='Go' />
                </form>
            </div>
        </td>
    </tr>
</table>
<BR>results here
ILMV
thanks. I closed the div and all is well. however i may clean it up as suggested.
Steven
Glad I could help. Yes it would be recommended you read up on good code readability, we've all been where you are, believe me it gets so much easier to read / debug when it's written cleanly. Also, observe how your check-box selected PHP tags are now embedded in your HTML, this is the best way to do this as the PHP engine doesn't have to output all that HTML, just the `selected='yes'`. Have a good day :)
ILMV