Post or Get w/o input boxes? Can I use onclick in

Results 1 to 5 of 5

Thread: Post or Get w/o input boxes? Can I use onclick in

  1. #1
    Doubletiger Guest

    Default Post or Get w/o input boxes? Can I use onclick in

    Hello,<BR><BR>I&#039ve been surfing the net and I also have a couple of books that I&#039m flipping through trying to find a way to create the next HTML page dynamically. More specifically, I want my user to click on a link and get a page generated from my database as the next HTML page. A user will click on a product category, (in a TOC frame on the left side of the site), and receive a page with thumbnails of all those category members. I don&#039t want to use radio/submit buttons. <BR><BR>Most code I find uses &#060;input&#062; boxes as the way to collect and send the data. I know there is a way to coordinate the onmouseup event in the &#060;a&#062; tag with the get or post method of the &#060;form&#062; tag. I suspect that JavaScript will have to capture the click event and that the VBScript/ASP will send the info to the next page. (I&#039m using VBScript as my ASP language.) The ASP on the next page can create the connString and RS to populate the page using the passed variable signifying the clicked link category. <BR><BR>From there I want each Thumbnail to be a link that passes the specific info to the next page if clicked. The next page will show a larger picture and details about the item. The TOC left side frame will always be available to the user in case they want to pick another category. If I had the link/get/post code I could adapt it for all these tasks. <BR><BR>I apologize if this code is out here in an obvious place. I just don&#039t know the "technical" name for the process and I suspect that is why I can&#039t directly find the code. <BR><BR>Any direction you can give me would be very appreciated.<BR>Thank you,<BR>Brenda<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Post or Get w/o input boxes? Can I use onclic

    I think a lot of what you want to do can be seen on my website:<BR><BR><BR>for example, I have a catalog of about 400 greeting cards. To show them all, I have just three asp pages:<BR>one that shows 1 to 8 at a time<BR>one that shows one at a time (larger image)<BR>one that shows the inside of a card (if there is one to show)<BR><BR>The user gets to see each card because the URL changes like this:<BR>xyz.asp?AA<BR>xyz.asp?AB<BR>etc. the AA or AB determines what card to show. The server queries the database and the database spits out the information required. <BR><BR>I also use a post that looks like a link. It works like a submit with javascript. In other words, you see a standard link (or click an image) and you get the same result as a radio button plus a submit click. Works GREAT! But its much easier than a standard form!<BR><BR>And to think I stole all of this stuff from the best websites out there. No one would ever know that in reality I have no idea what the heck I am doing!<BR><BR>True!<BR><BR>Edward

  3. #3
    Join Date
    Dec 1969

    Default Not a bad question...

    This is one you&#039d figure out on your own with more experience, but I can see how it might be tough to find when you are starting out.<BR><BR>There are two solutions.<BR><BR>The first is called a "query string". In your HREF, in addition to the name of the page you want to "hit" next, you also pass along some info. Such as:<BR><BR>&#060;A HREF=&#039makePage.asp?pageID=17&#039&#062;click here for page 17&#060;/A&#062;<BR><BR>A query string is specified by the ? that follows the URL. After the ? you can have several name=value pairs, each separated by the & character. <BR><BR>&#060;A HREF=&#039makePage.asp?pageID=17&homePage=A7&#039& #062;...&#060;/A&#062;<BR><BR>If you need to put any characters other than alphanumerics in as the values for the query string (that is, the values on the right side of each equal sign), then you need to encode those values. You *can* encode by hand, but you might find it easier to generate the encoded string using ASP and the Server.URLEncode function, thus:<BR><BR>&#060;A HREF=&#039makePage.asp?pageID=17&homePage=&#060;% = Server.URLEncode("3#xyz?M=92!") %&#062;&#039 &#062;...&#060;/A&#062;<BR><BR>******************<BR><BR>The other way to do this is indeed to use a form, but instead of using a radio button or something of that ilk, you use a *hidden* form field (or fieldS, if needed). This requires a tiny bit of script authoring. Something like this:<BR><BR>&#060;FORM Name="HiddenForm" Action="makePage.asp" Method=Post&#062;<BR>&#060;INPUT Type="HIDDEN" Name="pageID"&#062;<BR>&#060;/FORM&#062;<BR><BR>&#060;SCRIPT Language=JavaScript&#062;<BR>function nextPage( idValue )<BR>{<BR> &nbsp; document.HiddenForm.pageID.value = idValue;<BR> &nbsp; document.HiddenForm.submit( );<BR>}<BR>&#060;/SCRIPT&#062;<BR><BR>&#060;A HREF="javascript:nextPage(&#039#17-BG&#039);"&#062;See background page 17&#060;/A&#062;<BR><BR>Do you follow all that? Since the form has no visible elements, nothing from it appears on screen. When the user clicks on your &#060;A...&#062; link, the JavaScript function nextPage is called, with the argument #17-BG passed to it.<BR><BR>The script takes that argument and puts it into the value of the hidden form field and then submits the hidden form.<BR><BR>The advantage to this method (when the FORM is declared to be METHOD=POST) is that the user sees *nothing* in the browser address line to indicate what is taking place "under the covers". Personally, I *hate* query strings that put long strings of unintelligible (and possibly semi-secret!) stuff into the address lines of browsers, so I avoid it (and use this second technique) whenever possible.<BR><BR>There are, of course, circumstances where you do want to allow a querystring, such as when you want to tell outside users how to build a link to your page(s). Okay, fine. Do it. But otherwise...<BR><BR>***************<BR><BR>FINALLY ...<BR><BR>I should note that you can get the info passed by either method in your ASP page via:<BR><BR>Request.QueryString("pageID")<BR>Reque st.Form("pageID")<BR>Request("pageID")<BR><BR>The use of the first two of those should be obvious. The third form is a convenience: If you want to be able to get arguments for your page from *either* a query string or a form post, just don&#039t specify either one with the Request keyword and the system will automagically get the one the prior page used.<BR><BR>*****************<BR><BR>Does all *that* get you started??<BR><BR>

  4. #4
    Join Date
    Dec 1969

    Default RE: Not a bad question...

    I appreciate your suggestion! I tried the first one. I&#039m having trouble with the single and double quotes in the link, (or at least this is my suspicion). <BR>&#060;A HREF=&#039 target="main"&#039&#062;<BR>&#060;font color="blue"&#062;Blue¬*Stuff&#060;/font&#062;&#060;/A&#062;&#060;p&#062;<BR><BR>Could you give me any pointers on handling this code with frames?<BR>Thanks!!!<BR>Brenda

  5. #5
    Papa Zito Guest

    Default RE: Not a bad question...

    I&#039m probably a bit late in replying to this, but ohwell...<BR><BR>Remember that you seperate your parameters in the querystring using the & sign. Also, you don&#039t need to use any kind of quote marks... ASP knows that everything between the = sign and the following & sign is one piece. Your href should read :<BR><BR>&#060;A HREF=""&# 062;<BR><BR>If "target" isn&#039t actually a parameter, and you&#039re trying to tell the link where to go, you use the base target tag, which is actually plain vanilla HTML...<BR><BR>&#060;base target="main"&#062;<BR><BR>This goes in the &#060;head&#062; section of your file. Remember, capitalization counts! "main" and "Main" are two different frames!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts