Welcome Guest, Not a member yet? Register   Sign In
Any Solution for IE7 Button Value bug? [SOLVED]
#1

[eluser]Otemu[/eluser]
Code:
Hi,

I have a simple form with several button elements
[code]
<button name="selectedTab" type="submit" value="topten">TOP TEN</button>
<button name="selectedTab" type="submit" value="wins">WINS</button>
<button name="selectedTab" type="submit" value="losses">LOSSES</button>

However the value actually submitted is different for IE6/IE7, for instance if a user clicks the top ten button, other browsers submit the actual value of 'topten' but IE6/IE7 submits the actual text of'TOP TEN'

I have seen the solution to use hidden input, this method is fine, however since my form contains mutiple buttons, I basically have to have different forms for each hidden input which is not idea.

The current method I am using is to check for both values, which doesnt seem great, wondering if anyone has any other solutions?
Code:
if(($selectedTab=="topten")||($selectedTab=="TOP TEN"))

#2

[eluser]InsiteFX[/eluser]
Important: If you use the <button> element in an HTML form, different browsers may submit different values.
Internet Explorer, prior version 9, will submit the text between the <button> and </button> tags,
while other browsers will submit the content of the value attribute. Use the &lt;input&gt; element to create
buttons in an HTML form.
#3

[eluser]Otemu[/eluser]
[quote author="InsiteFX" date="1332081705"]Important: If you use the <button> element in an HTML form, different browsers may submit different values.
Internet Explorer, prior version 9, will submit the text between the <button> and </button> tags,
while other browsers will submit the content of the value attribute. Use the &lt;input&gt; element to create
buttons in an HTML form.
[/quote]

Thanks for your feedback, I did say I could use hidden input just that it means if I have 8 buttons, I need to have 8 different forms for each button so was wondering if anyone knew any other techniques.

Thanks
#4

[eluser]mackski[/eluser]
Providing your using PHP, you could just do this in your form:
Code:
&lt;input type="submit" name="selectedTab[wins]" value="wins"&gt;
&lt;input type="submit" name="selectedTab[topten]" value="topten"&gt;

And in your controller:
Code:
if($selected = key($_POST['selectedTab'])) {
   switch($selected) {
      case "wins": echo "You win"; break;
      case "topten" : echo "Top Ten"; break;
   }
}
#5

[eluser]Otemu[/eluser]
[quote author="mackski" date="1332154365"]Providing your using PHP, you could just do this in your form:
Code:
&lt;input type="submit" name="selectedTab[wins]" value="wins"&gt;
&lt;input type="submit" name="selectedTab[topten]" value="topten"&gt;

And in your controller:
Code:
if($selected = key($_POST['selectedTab'])) {
   switch($selected) {
      case "wins": echo "You win"; break;
      case "topten" : echo "Top Ten"; break;
   }
}
[/quote]

Hi,

Yes this is more or less similar to what I have implemented, however using an if else statement. Looks like handling the two different values is the best option.

Well I consider this issue closed now, thanks for feedback guys :-)
#6

[eluser]Unknown[/eluser]
I really like mackski's idea,

In case you are looking to still have a name => value on the submit,
you can also trigger the submit button with a label. Then you can style the label as a button.

Code:
<label for="action_update" class="button">
&lt;input type="submit" id="action_update" name="action" value="update" /&gt; <span>Update this profile</span>
</label>

&lt;style type="text/css"&gt;
.button{ overflow: hidden; }
.button input{ position: absolute; top: -999%; }

I agree, this code is a bit long to make IE6/IE7 simulate a button, but it still work.




Theme © iAndrew 2016 - Forum software by © MyBB