160 users online (0 members and 160 guests)  


  Results 1 to 10 of 10

Related

  1. input type= image vs. submit    Forum: HTML Forum
    Replies: 5
  2. Replies: 3
  3. onSubmit sends email of form data    Forum: HTML Forum
    Replies: 2
  4. Replies: 14
  5. How do I swap an image for BOTH an image and a sound?    Forum: Website Scripts Forum
    Replies: 1
  1. #1
    gohatesusall's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2002
    Location
    in de middle of germany
    Posts
    7

    Submit with Image tag that sends its own value

    Hi.

    On monday we had to code a form for a shop system. You can take goods in a shopping cart, and we wanted the customers to be able to delete single goods from it. No Problem with the boring gray Submit-Button, but how to make with an input type image? ALl i have to know is, if theres any possibility of senden an input type=images´value?
    The necessity results from the structure of the shopping cart. You have a row for each good, and even a delbutton for each good.
    So if i could request the value, i knew which good must be deleted.

    I hope someone understands me.

    Greetings, GodHatesUsAll

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi there. Welcome to the forums.

    If you give the input a name, it will be picked up as a POST variable in the form. so -

    Code:
    <input type="image" src="sflogo.jpg" name="SUBMITBUTTON" value="Hello">
    So this will work.

    On a related note, not a lot of people know that if you use an image submit in this way, it also transmits the X and Y coordinates of the image, ie - where the user clicked the image. QUite handy.

    The POST array for above looked like this -

    Code:
    Array ( [SUBMITBUTTON_x] => 12 [SUBMITBUTTON_y] => 9 [SUBMITBUTTON] => Hello )
    So you should be able to pick up that information with whatever script you are submitting to.

    Hope that helps.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    gohatesusall's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2002
    Location
    in de middle of germany
    Posts
    7
    Nice try, but it doesnt work...
    I really dont know why? I built a testsite on http://www.mkunz-asp.de/image/send.htm
    which only send an input type=image to the "get.asp". After request.form there is nothing in my variable. Maybe if you see my code, you can tell me what im doing wrong.

    THX

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Seems to be working.

    Obviously, I do not see your asp code, but it seems to be writing 'Hello' (the value of the button) and then 'leer' the value of the text box.

    So I guess you got it! Unless I misunderstood the problem.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    gohatesusall's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2002
    Location
    in de middle of germany
    Posts
    7
    Thats really disgusting. I cant see the text "hello" when i call the page...
    Maybe it depends on the used browser?
    Im using ie6, should work?
    we now are very confused about it.
    have you some working code on the net?
    So please show me...
    THX

    addon: oh yes i see. in netscape it is shown, in ie not. so really THX

    addon2: if there is any idea, why IE doesnt like the formheader, please post...
    Last edited by gohatesusall; 11-07-2002 at 08:24 AM.

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    I see what you mean, my IE does the same (I use Mozilla by default).

    I would guess there is something wrong with your get.asp script.

    Try simplifying it -

    Code:
    <%
    response.write(request.form("text") & " " & request.form("SUBMITBUTTON") & "<br />")
    %>
    I would also try changing the 'name' of the text input from 'text', as this is a reserved word in ASP, I think, so it may be cuasing confusion.

    Anyway, try a file with just the above in, see what happens.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  7. #7
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Don't even bother.

    Microsoft deliberately ignore any value in this type of submit. They send the x and y coords (these, but no value!) but ignores value.

    The specs are outlined here -

    http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/type_7.asp

    Even if you use a different scripting language, Internet Explorer is not sending the information in the first place, so there isn't much you can do. Sorry.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  8. #8
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    I just read up on the DOM specs for the element too, html4.0.

    It doesn't mention of value to be passed, but it does imply it. grr.

    If interested, its here

    http://www.w3.org/TR/1998/REC-html40...tml#edef-INPUT
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  9. #9
    gohatesusall's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2002
    Location
    in de middle of germany
    Posts
    7
    Thats really disappointing. So we have to develope another solution. But THXALOT!! I had to mention that a long time before posting... (-; THXALOT!!

    Last edited by gohatesusall; 11-08-2002 at 03:34 AM.

  10. #10
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316
    i suggest that u do this:

    have 1 submit button, and each row have a checkbox. when displaying each row (i'm assuming you're using a productid or have some way of identifying each product),

    <%
    response.write "<tr><td><checkbox name='pdt1' value='" & ProductID & "'></td>"

    response.write "<img src='url.jpg' onClick='addproduct();'>"
    %>

    then use javascript to submit the form
    (between <head> and </head>)

    <script language='Javascript'>
    <!--
    function addproduct
    {
    document.formname.submit();
    }
    -->
    </script>

    this way, u can tell which product was chosen
    use a different page to process add,delete etc
    compartmentalizing makes it easier to debug
    hope this helps



Tags for this Thread