/    Sign up×
Community /Pin to ProfileBookmark

IE doesn’t return value of submit button?

Here is a form (it is the output of a jsp, but that’s irrelevant at this point). This was cut and pasted directly from Internet Explorer’s View->Document Source menu:

[CODE]
<form method=”post” action=”/infoisland/members/servlet/TribeMgr”>
<fieldset>
<legend>New Tribe </legend>
<label for=”trbname”>Tribe Name (32 chars):</label>
<input type=”text” name=”trbname” class=”frmtxt” value=”Title
goes here” />
<br class=fieldalign />

<label for=”trbdesc”>Tribe Description</label>
<textarea rows=”5″ cols=”32″ name=”trbdesc”
class=”leftlabeled”>Description goes here</textarea>
<br class=fieldalign />
<div class=”break”>
<p><input type=”checkbox” name=”mod” class=”check” />
Moderated Tribe (all messages screened by the Tribal
Chief)</p><br class=”fieldalign”>
<p><input type=”radio” name=”access” value=”public” >Anyone can
join this tribe</p>
<p><input type=”radio” name=”access” value=”protected” checked>A
member must invite someone to join</p>
<p><input type=”radio” name=”access” value=”private” >The chief
(currently you) must invite
someone to join (a member can request this of the chief)</p>
</div>
</fieldset>

[B]<button type=”submit” name=”trbbtn” value=”trbnew”
class=”centeredbutton”>New Tribe</button>[/B]
<br class=”fieldalign” />
</form>
[/CODE]

Note at the end where I’ve bolded the button. Here is a fragment of the TrbMgr servlet this form calls:

[CODE]
String target= “”;
String todo= rq.getParameter(“trbbtn”);

Log.write(“n**********nTribeMgr: todo= ” + todo);
[/CODE]

And, here is what the log prints out:

[QUOTE]


**********

TribeMgr: todo= New Tribe

[/QUOTE]

In other words, IE is sending the text on the button and not the “value=’btnvalue'” from the <input> tag.

Mozilla works just fine, and I don’t think I’ve ever seen this. Has anyone else? Is this a quirk in IE I don’t know about? I did a google search and haven’t found anything so far.

TIA
anw

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 26.2007 — The simplest solution would be to use a [b]<input type="submit">[/b] element instead of a button element, as IE handles that correctly. If it is essential that you use a button element, then you might want to add a hidden field to transmit the necessary post name/value pair instead of depending on the button's value.
Copy linkTweet thisAlerts:
@anwauthorMar 27.2007 — Hmmm! I used a button (as opposed to an input/submit) for a particular reason, and now can't remember what it was, so I guess I'll change it back. I actually changed the servlet to look for the value or the substring "New" (the other choice being "Update"), but that's a kludge to accommodate a flaw in IE. The thing that really surprised me was that I hadn't heard or seen anything about this before. Seems like it would be pretty well known.

BTW, great quote from Terry Pratchett, one of my favorite authors.

Thanks.
Copy linkTweet thisAlerts:
@sitehatcheryApr 04.2007 — I'm having a similar problem with IE7 only.

[code=php]
<form action='search_results.php' method='post'>
<input type='text' name='search' value='search' onclick="this.value='';">
&nbsp;<input type='submit' value='go' name='go_search'>
</form>
[/code]


If I click the button, it works. If I just press enter or return after inputting the value, it doesn't return any results.

P.S. The same problem occurs with or without onclick="this.value='';"

You can see what I mean by going to at www.bidwellpark.org
Copy linkTweet thisAlerts:
@anwauthorApr 05.2007 — Mine was different, because I was using the <button> tag instead of the <input type="submit"...> tag. What I finally did was add an onsubmit Javascript event to my form &, using the DOM, set the button's value in a Javascript event handler. That's working, but why IE has a problem with buttons, I don't know. It's also weird that it doesn't seem to be more generally known; in fact, that seems to indicate that it's something besides just a generic lack of support for the <button> tag, but I got it working.
Copy linkTweet thisAlerts:
@sitehatcheryApr 05.2007 — Ok, easy enough solve, though this is a problem with IE7.

[code=php]
<form action='search_results.php' method='post'>
<input type='text' name='search' value='search' onclick="this.value='';">
&nbsp;<input type='submit' value='go'>
</form>
[/code]


Rather than giving the button a name, I just processed the form if the search post value was not empty.

edit: or you can add a hidden field
×

Success!

Help @anw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...