Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Submit Button

by Anonymous Monk
on Mar 20, 2001 at 00:02 UTC ( [id://65524]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How would I use an image button (ie button.jpg) to submit information to another page? For instance, if I had name, address, phone, email on one form and I need the same info to appear on the next form without searching the database again. I know how to do this using "form method=post..." but I need to use an image button.

Replies are listed 'Best First'.
Re: Submit Button
by arturo (Vicar) on Mar 20, 2001 at 00:12 UTC

    I'm not sure what you mean by 'using an image button' in this context. Your problem is that you need to pass a bunch of data between two CGI scripts (or between invocations of one program).

    One way to pass information between CGI scripts is to pass things around in GET or POST fields (as you've apparently considered). But what's the problem here? If the user is going to click on a submit button, then they're submitting a form, and so the information can be passed. If you don't want the information popping up in textfields, get to know and love the hidden type of form variable. Or you might set the information from the DB as the value of a cookie when you do the fetch from the DB, and read the cookie in on successive invocations.

    There are other possible solutions, but we should probably wait to see what you really meant by your question before giving solutions =)

    HTH

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      The earlier post is absolutely right...of course.. I wonder if you want something a little bit more basic, ie: using an image to replace the default "submit" button inside a form

      if this is the case, then this snippet of HTML should work

      <input type="image" name="button" src="images/bttn_download_now.gif" w +idth="125" height="18">

      This replaces the submit button with "bttn_download.gif".. the only difference that you notice is that two extra parameters, x coordinate and y coordinate of the image clicked on by the user, is passed into your script..

      so, what you should do is replace the submit button with that above, replacing path to image as necessary... then, use either the GET/POST variables to populate the form elements in the next page, or use a cookie (see earlier post) or use hidden fields..
      HTH

      I want to use an image(ie button.jpg) instead of the default submit button that is created to submit the form.
Re: Submit Button
by sutch (Curate) on Mar 20, 2001 at 00:15 UTC
    I believe that you are asking for the HTML to allow the use of an image instead of a button to submit a form. If so, use:

    <input type="image" src="image.gif" alt="alt_text" name="submit_name" value="submit_value">

      I believe you may have left out the src attribute:

      <input type="image" name="whatever" value="andever" src="button.jpg">

      ... but I've been wrong about what web browsers will accept in the face of overwhelming specifications before. :)

        Thanks chromatic. I had realized that I left out the src attribute just after I submitted that response, and then updated it immediately.
Re: Submit Button
by knobunc (Pilgrim) on Mar 20, 2001 at 00:24 UTC
    Not that this has much to do with Perl in particular, but...

    You can do something like the following:

    <form method='post' action='http:/whatever.com/foo'> Address: <input type='text' name='address'> ... <input type='image' name='whatever' src='url-to-image.jpg' border=0> </form>
    Or if that does not do what you want, you will have to do Javascripty things:
    <form name='form_name' method='post' action='http:/whatever.com/foo'> Address: <input type='text' name='address'> ... <img src='url-to-image.jpg' onClick='document.form_name.submit()'> </form>
    You can do the same kind of thing with simple link () tags too. But people need to have Javascript enabled.

    -ben

Re: Submit Button
by Masem (Monsignor) on Mar 20, 2001 at 01:18 UTC
    Others have answered the question already about using an image button for submitting data. I think the other part of your question (same info to appear on next form), assuming that you've already gotten this data once prior to displaying form 1, is to use hidden fields in the form to transfer it. For example:
    <INPUT TYPE="hidden" NAME="name" VALUE="John Q. Smith"> <INPUT TYPE="hidden" NAME="address" VALUE="1600 Pennsylvia Avenue">
    They will not be visible to the typical user (though they are visible in the source), and you can access these as if they were text fields in the second CGI script you have.
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
      Alternatively, set one hidden field or cookie with a unique identifier and maintain the information on the server.

      I also need to correct Masem's post, since we now know:

      <INPUT TYPE="hidden" NAME="name" VALUE="George W. Bush"> <INPUT TYPE="hidden" NAME="address" VALUE="1600 Pennsylvia Avenue">
      :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://65524]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-24 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found