Jump to content

Submit by image


Recommended Posts

Hi all,I created a program that checks if the item named “mysubmit” contains the value “Print”, if so, printing action will be taken. When I use input type “submit” it works fine.<input type="submit" name="mysubmit" value="Print">Instead of a submit button, I would like to use an image (and the item name and value passed to my program), so I tried:<input type="image" name="mysubmit" value="Print" src="images/printer.png">In this case my program does NOT recognize the item name and/or the value.Anyone have any idea what I am doing wrong and how I could solve it?Thank you in advanceRob

Link to post
Share on other sites
Hi all,I created a program that checks if the item named “mysubmit” contains the value “Print”, if so, printing action will be taken. ...
What kind of program? Can't tell enough from your description to know what the problem might be. Can you post the code that does the check?
Link to post
Share on other sites

Image buttons don't send their value, instead they send the X and Y coordinates that the user clicked on. If the name is mysubmit, then it will send mysubmit_x and mysubmit_y (I think). If you're using PHP, you can print the $_POST array to see everything that gets submitted:print_r($_POST);

Link to post
Share on other sites
Thank you for all your respons!I use MicroFocus Server Expres (Cobol) and it recorgnize the item name and value when I use input type submit.Is there no way at all to send the name and value when I use input type image?Rob
Let's assume that's the webserver, and the html is a public web page. In that case, currently the submit button will be part of an html form, and when it's clicked, the form fields are sent to the webserver in the normal way.The webserver then executes cobol code you wrote to interpret the form fields submitted. If your <input> change
<input type="image" name="mysubmit" value="Print" src="images/printer.png">
has stopped things working, I think the cobol logic may be incorrect. Because if you paste your new <input> into this w3schools try-it editor and click the image placeholder, it submits the form and shows the following results:
Your input was received as:FirstName=Mickey&LastName=Mouse&mysubmit.x=8&mysubmit.y=11&mysubmit=Print
As you can see, the results include x-y coordinates (as justsomeguy thought) but also the value "Print" which you are expecting.Can you post your code that interprets the form fields submitted?
Link to post
Share on other sites
Is there no way at all to send the name and value when I use input type image?
The spec says this:
When a pointing device is used to click on the image, the form is submitted and the click coordinates passed to the server. The x value is measured in pixels from the left of the image, and the y value in pixels from the top of the image. The submitted data includes name.x=x-value and name.y=y-value where "name" is the value of the name attribute, and x-value and y-value are the x and y coordinate values, respectively.
It doesn't say anything about what to do with the value of the element, so some browsers may submit the name/value pair and others may not. It's not something you can count on though. If you want to send a name/value when you hit the button you'll need to put a Javascript function on the button that will create a new hidden input with the name and value you want to submit.
Link to post
Share on other sites
The spec says this:It doesn't say anything about what to do with the value of the element, so some browsers may submit the name/value pair and others may not. It's not something you can count on though. If you want to send a name/value when you hit the button you'll need to put a Javascript function on the button that will create a new hidden input with the name and value you want to submit.
No need for javascript, just add the hidden field to the form:
<input type="hidden" name="mysubmit" value="Print">

EDIT: Or does the page have just the one form, with several submit buttons? In that case you could still add the hidden field to the form, just use javascript to set its value. But if you use more than one form, each with its own submit button, that would let you add a hidden field to each with a fixed value. If you have further queries please post the full html form(s) so we know what we're dealing with. :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...