Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Button Vs HyperLink

    The following code is giving me trouble?

    <%

    response.write "<P Class=SubTitle><A HREF='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"' onClick=""this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"';"" Target=_Blank>Click Here to view what the Memorial will look like!</A><BR />No password checks will be used</p><br />"

    response.write "<input type='submit' value='Go Back' onClick=""this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"';"">"

    %>

    the button works fine yet the hyperlink gives me a javascript error that says

    'this.form' is null or not an object

    then when the page loads none of the form fields get transmitted?

    Also how do I get a button to open in a new window useing target without putting the target in the form field? cause I will be useing the form fields for multiple links!
    Last edited by Crash1hd; 11-07-2003 at 12:59 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "this.form" only works for form field elements, not just any element between the <form> and </form> tags. You need to use another mechanism to get to the form object from within a link tag.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    That's true, but more to the point, why are you setting the form's .action property in the hyperlink at all?

    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To have multiple links in the Form! that reflect to the form

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    Originally posted by Crash1hd
    To have multiple links in the Form! that reflect to the form
    I can make no sense of that, I'm afraid!! What do you mean "reflect"?



    My point was that you are setting the .action property of the form from within the link, but you aren't calling the .submit() method, so it's not actually achieving anything.!! It's also duplicating the code in the onclick event of the submit button...!

    Basically, the URL within the href is perfectly adequate.

    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok here is the code! Broken down!

    Code:
    <form action="Purchase_Mem.asp?dbshow=4" method="post">
    
    		<input type="hidden" name="submitnumber" value="<%=submitnumber%>">
    
    <select size="1" name="PurchaseField" onchange="this.form.action='Purchase_Mem.asp?dbshow=2&backcheck=1&PurchaseField='+this.options[this.selectedIndex].value;this.form.submit();">
    
    <%
    
    response.write "<P Class=SubTitle><A HREF='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"' onClick=""this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"';this.form.submit();"" Target=_Blank>Click Here to view what the Memorial will look like!</A><BR />No password checks will be used</p><br />"
    
    response.write "<P Class=SubTitle><input type='submit' value='Go Back' onClick=""this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"';""></p>"
    
    %>
    
    		<td align="center">
    			<input type="submit" value="Confirm">&nbsp;&nbsp;&nbsp;
    			<input type="submit" value="Go Back" onClick="this.form.action='Purchase_Mem.asp?dbshow=4&PurchaseField=<%=Request.Querystring("purchasefield")%>';">
    		</td>
    	</tr>
    </table>
    </form>
    I understand that this

    <%

    response.write "<P Class=SubTitle><A HREF='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"' onClick=""this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"';"" Target=_Blank>Click Here to view what the Memorial will look like!</A><BR />No password checks will be used</p><br />"

    %>

    should be this

    <%

    response.write "<P Class=SubTitle><A HREF='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"' onClick=""this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"';this. form.submit();"" Target=_Blank>Click Here to view what the Memorial will look like!</A><BR />No password checks will be used</p><br />"

    %>

    But I still get the javascript error?

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    Your code is making less and less sense the more I see of it!

    1) If the user lets the form load and presses Confirm, then dbshow=4 will be passed in the querystring, and PurchaseField= (no value) will be passed as part of the form POST. Why on earth do you want that?

    2) Your <select> element contains no <option> elements, and therefore doesn't give the user anything to choose from, and won't pass any values. It also lacks a closing </select> tag.

    3) In this line:
    Code:
    response.write "<P Class=SubTitle><A HREF='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"' onClick=""this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"';this.form.submit();"" Target=_Blank>Click Here to view what the Memorial will look like!</A><BR />No password checks will be used</p><br />"
    You are still trying to use this.form to get a reference to the form object despite Roy telling you that's not going to work (in post #2 in this thread)!! And my point about the script in the onclick event being useless still remains. So here's a different approach... is there a good reason why you CAN'T do this:
    Code:
    response.write "<P Class=SubTitle><A HREF='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request.Form("Mtemplate")&"' Target=_Blank>Click Here to view what the Memorial will look like!</A><BR />No password checks will be used</p><br />"
    4) Although it's not technically required for HTML, you should ensure that all attribute values are enclosed in quotes (preferably the same type too), which you are not currently doing - see the Class and Target attributes above.


    There's more I could say, but I'll leave it there. Please respond to the points above (and re-read the other posts in this thread), and then explain in words exactly what you are trying to do on this page - i.e. what the purpose of each of the select element, links, and buttons is/are.

    Last edited by M@rco; 11-09-2003 at 11:53 AM.
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Lol The code that I gave is only a fraction of the entire code the entire code is over 3000 lines long its a really large page! I am going to quote another post I had done in javascripts as to what I want to do!



    http://www.codingforums.com/showthre...695#post147695

    I will have form fields that after you fill in and click submit it goes to a confirm page on that confirm page there will be a link at the bottem that says click here to view sample of what it will look like in not so many words! When you click that link it opens a small page with everything in the form that you entered! After the user likes what they see they close it which puts them back on the main page at the bottem has to buttons complete and go back when you click on those buttons it takes the same form info to the next page but not in a new window! Which is why i am unable to use a button for the samples cause to make it open into a new window the form field has to look as follows

    <form action="webpage" method="post" target="_Blank">

    The problem with that is that all the buttons would open a new page, so I have to use a link that I can specify how it opens new page or not! yet I always get an error useing a link instead of a button however I have used dropdowns which would reload the page and onload with specific info it will open the new page but I would rather not have to use a dropdown and have to refresh the page!

    I hope that makes sense
    I understand that it can seem to be vague with what I had given for information however If I where to post the entire code well lets just say short of uploading a file I wont be able to do that!

    I hope that helps!

  • #9
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    Crash, I have done my best to help you but we clearly don't seem to be communicating...! I hope someone else is able to help you better instead.

    NEXT!
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #10
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    NP! I really do appreciate all the help sometimes I just cant be helped!

  • #11
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found the following code works great! does exactly what I was looking for

    this.form.target='_blank';

    inside the button field as follows

    <input type='submit' value='Click Here' onClick=""this.form.target='_blank';this.form.action='Purchase_Mem.asp?dbshow=4&Mtemplate="&Request. Form("Mtemplate")&"';"">

    I dont know why I didnt see it sooner!

    Thanks anyhow!


  •  

    Posting Permissions

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