?
Solved

<BUTTON> tag submits 'innerText' content instead of 'value'

Posted on 2004-11-11
7
Medium Priority
?
294 Views
Last Modified: 2008-03-03
In Internet Explorer 6.0

<form action="" method="get">
<input type="text" value="ddd" name="sampletext">
<button name="samplebutton" VALUE="correct" type="submit"><IMG SRC="openwindow16x16.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT="" hspace=4 align="middle">Submit</button>
</form>

How can I submit 'correct' value using "BUTTON" tag?
0
Comment
Question by:maximkr
  • 5
  • 2
7 Comments
 
LVL 6

Expert Comment

by:mosphat
ID: 12552909
<form action="" method="get">
<input type="text" value="ddd" name="sampletext">
<button name="samplebutton" onclick="this.form.samplebutton.value='correct';this.form.submit();"
><IMG SRC="openwindow16x16.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT="" hspace=4 align="middle">Submit</button>
</form>

But you'll see the button change shortly before submitting.

If that's not what you want, why not use a hidden field to transfer the value, like this:

<form action="" method="get">
<input type="text" value="ddd" name="sampletext">
<input type="hidden" name="samplebutton" value="correct">
<button name="dummy" onclick="this.form.samplebutton.value='correct';this.form.submit();"
><IMG SRC="openwindow16x16.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT="" hspace=4 align="middle">Submit</button>
</form>
0
 
LVL 6

Expert Comment

by:mosphat
ID: 12552913
In that last option you'd leave out 'this.form.samplebutton.value='correct';'. My mistake.
0
 

Author Comment

by:maximkr
ID: 12552956
> onclick="this.form.samplebutton.value='correct';this.form.submit();"

We need a solution without javascript. Actually, the 'value' of button is not important for us. Can some 'innerHTML' values cause any vulnerabilities?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Accepted Solution

by:
mosphat earned 500 total points
ID: 12552980
You mean whether having &samplebutton=%3CIMG+height%3D16+alt%3D%22%22+hspace%3D4+src%3D%22openwindow16x16.gif%22+width%3D16+align%3Dmiddle+border%3D0%3ESubmit
in your URL can be harmfull? The answer is no, not as long as you don't actually use the samplebutton value somewhere.
It's just not a very pretty sight, I guess.
0
 
LVL 6

Expert Comment

by:mosphat
ID: 12553011
If you leave out the name="samplebutton" part, it will work too, without sending a value along (since it isn't important anyway):

<form action="" method="get">
<input type="text" value="ddd" name="sampletext">
<button type="submit"><IMG SRC="openwindow16x16.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT="" hspace=4 align="middle">Submit</button>
</form>
0
 

Author Comment

by:maximkr
ID: 12553031
>If you leave out the name="samplebutton" part, it will work too, without sending a value along

we use 'name' parameter to detect, which button was pressed.
Is seems, 'button' problem is IE-specific. In Mozilla browser all values submits fine.
0
 
LVL 6

Expert Comment

by:mosphat
ID: 12553059
I don't think that IE bug can be solved without resorting to javascript.
Unless you take the %3CIMG+height%3D16+alt%3D%22%22+hspace%3D4+src%3D%22openwindow16x16.gif%22+width%3D16+align%3Dmiddle+border%3D0%3ESubmit
into account when determining which button was pressed on the server side of course.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I spend far too much time on the web keeping up with the news: politics, the environment, computer stuff, the Experts Exchange. It's never-ending. But many of the most informative web pages are overwhelmed with noise: scrolling banners, flashing tex…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question