dcsimg
www.webdeveloper.com
Results 1 to 11 of 11

Thread: Button As A Href

  1. #1
    Join Date
    Feb 2006
    Location
    Springfield, MO
    Posts
    71

    Button As A Href

    I am trying to use buttons on a page to call other pages. I accomplish (in firefox at least) this by making the button an <a href> tag. The buttons are within a form that does have a submit button as well however these link buttons are not submitting any info.

    Guess where I am thrown off is that it works in firefox but not ie.

    any help would be cool.

    Code:
    <body>
    
    <table>
    <tr>
    <td><img src="images/new_globe.gif"></td>
    <td><img src="images/header2.gif"></td>
    </tr>
    
    </table>
    <%'determine if this is the first visit to the page
    
    getCurrentHBL="SELECT * FROM tblHBL WHERE HBLID = " & hblID & ""
    set currentHBL=oCmd.execute(getCurrentHBL)
    
    
    		IF currentHBL.eof THEN
    			response.write("ERROR RETRIEVING CURRENT INFORMATION")
    		ELSE
    		%>
    		<form action="HBL_add_item3.asp?hblID=<%=currentHBL(0)%>" method="post">
    
    		<table cellpadding="4" cellspacing="4">
    		<input type="hidden" name="hblID" value="<%=currentHBL(0)%>">
    		<input type="hidden" name="customer2" value="<%=currentHBL(2)%>">
    		<input type="hidden" name="MBL" value="<%=currentHBL(18)%>">
    <%
    
    'Open connection with database DSNless connection string.
    Set oCmd = Server.CreateObject("ADODB.Connection")
    oCmd.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(DatabaseFolder2) 
    
    'gets master bull number for display using autoID passed from previous page
    masterSQL="SELECT MasterBill FROM tblMaster WHERE MasterID = " & currentHBL(18) & ""
    
    set masterTemp = oCmd.execute(masterSQL)
    %>
    
    	<tr>
    		<td><b>Master Bill Number</b></td>
    		<td><b><%=masterTemp("MasterBill")%></b></td>
    	</tr>
    			<tr>
    				<td><b>Exporter</b></td>
    				<%'gets exporter information
    				expSQL="SELECT Name FROM tblExporter WHERE ExpID = " & currentHBL(1) & ""
    				set expTemp = oCmd.execute(expSQL)%>
    				<td><%=expTemp(0)%></td>
    				<td><b>Consigned To</b></td>
    				<%'gets customer information
    				custSQL="SELECT Name FROM tblCustomer WHERE CustID = " & currentHBL(2) & ""
    				set custTemp = oCmd.execute(custSQL)%>
    				<td><%=custTemp(0)%></td>
    				<td rowspan="9" width=120>&nbsp;</td>
    				<td rowspan="9"><p><a href="HBL_index.asp"><input type="button" name="complete1" value="Complete Master Bill"></a></p>
    				<a href="HBL_create.asp?MBL=<%=currentHBL(18)%>"><input type="button" name="complete" value="Add New HBL to Master"></a></td>
    			</tr>
    		
    			<tr>
    				<td><b>Notify Party/Intermediate Consignee</b></td>
    				<td><%=currentHBL(3)%></td>
    				<td><b>Forwarding Agent</b></td>
    				<td><%=currentHBL(6)%></td>
    			</tr>
    		
    			<tr>
    				<td><b>Document #</b></td>
    				<td><%=currentHBL(4)%></td>
    				<td><b>House Bill of Lading</b></td>
    				<td><%=currentHBL(5)%></td>
    			</tr>
    		
    			<tr>
    				<td><b>Point(State) of Origin or FTZ Number</b></td>
    				<td><%=currentHBL(7)%></td>
    				<td><b>Type of Move</b></td>
    				<td><%=currentHBL(9)%></td>
    			</tr>
    		
    			<tr>
    				<td><b>Containerized (Vessel)</b></td>
    				<td><%=currentHBL(10)%></td>
    				<td><b>Pre-Carriage by-</b></td>
    				<td><%=currentHBL(11)%></td>
    			</tr>
    		
    			<tr>
    				<td><b>Exporting Carrier</b></td>
    				<td><%=currentHBL(13)%></td>
    				<td><b>Place of Receipt</b></td>
    				<td><%=currentHBL(12)%></td>
    			</tr>
    		
    			<tr>
    				<td><b>Port of Loading/Export</b></td>
    				<td><%=currentHBL(14)%></td>
    				<td><b>Port of Unloading</b></td>
    				<td><%=currentHBL(15)%></td>
    			</tr>
    		
    			<tr>
    				<td><b>Final Delivery</b></td>
    				<td><%=currentHBL(16)%></td>
    				<td><b>Loaded on Board</b></td>
    				<td><%=currentHBL(17)%></td>
    			</tr>
    		
    			<tr>
    				<td><input type="submit" value="Add New Item" name="Submit"></td>
    				<td></td>
    				<td></td>
    				<td></td>
    			</tr>
    		
    		
    		</table>
    		
    		</form>
    		<%END IF%>
    		
    
    <table border=1>
    	<tr>
    		<td><b>P.O. #</b></td>
    		<td><b>Seal #</b></td>
    		<td><b>Container #</b></td>
    		<td><b>Container Type</b></td>
    		<td><b># of Packages</b></td>
    		<td><b>Gross Weight (in KG)</b></td>
    		<td><b>CBM</b></td>
    	</tr>
    
    
    <%	
    	'obtain all descriptions
    	getDesc="SELECT * FROM tblDescription WHERE HBL_ID = " & hblID & ""
    	set desc=ocmd.execute(getDesc)
    
        do until desc.eof
    
    %>
    
    
    	<tr>
    		<td><%=desc(3)%></td>
    		<td><%=desc(4)%></td>
    		<td><%=desc(5)%></td>
    		<td><%=desc(6)%></td>
    		<td><%=desc(7)%></td>
    		<td><%=desc(8)%></td>
    		<td><%=desc(9)%></td>
    	</tr>
    
    <%	desc.movenext
    	loop
    	desc.close
    	set desc=nothing
    %>
    </table>
    </body>
    Last edited by orionbrock32; 09-19-2006 at 11:37 AM.

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia
    Posts
    125
    You need to use a javascript event to make the page go somewhere

    <input type="button" name="complete1" value="Complete Master Bill" onClick="window.navigate('URL')">

  3. #3
    Join Date
    Mar 2006
    Posts
    591
    Vanny is correct.
    The easiest way to do this is to use Javascript.

    If you want to open the link in a different page use :

    window.open('url') instead of window.navigate('URL')

  4. #4
    Join Date
    Feb 2006
    Location
    Springfield, MO
    Posts
    71
    i found a code that worked. does this look like there would be a problem?

    Code:
    <INPUT TYPE="button" name="complete1" value="Complete Master Bill" onClick="parent.location='HBL_index.asp'">

  5. #5
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972
    Yes, it's completely useles for anyone who doesn't have Javascript enabled. It sounds like you might as well just style an A element to look like a button.

  6. #6
    Join Date
    Feb 2006
    Location
    Springfield, MO
    Posts
    71
    is there a way to do a check and see if java script is enabled and then run an if statement like:

    Code:
    IF javascript enabled THEN
    
    <INPUT TYPE="button" name="complete1" value="Complete Master Bill" onClick="parent.location='HBL_index.asp'">
    
    ELSE
    
    <a href="HBL_index.asp"> Link</a>
    
    END IF

  7. #7
    Join Date
    Dec 2003
    Location
    England, UK
    Posts
    432
    just use css to style an anchor the same as your form buttons.

    it's really not a good idea to overcomplicate things like your "if" would.

  8. #8
    Join Date
    Feb 2006
    Location
    Springfield, MO
    Posts
    71
    I guess that didn't look at it that way. I was trained in VB and having to learn the web stuff on my own. And they taught me in VB that you can solve anything with an IF statement

  9. #9
    Join Date
    Jan 2009
    Posts
    6
    Just because you CAN solve it with an IF statement doesn't mean you should

  10. #10
    Join Date
    Dec 2007
    Location
    Dayton, OH
    Posts
    390
    Please please please PLEASE do not use JavaScript to make a button click. That is terrible usability. ASP can not detect if JS is enabled anyways.

  11. #11
    Join Date
    Aug 2009
    Posts
    1

    No need for JavaScript for button link

    JavaScript isn't necessary to make a button work like a link. Buttons are meant to submit forms, and if the button is the only thing in the form then it has the same effect as clicking a link. E.g.:

    <form action="test.html" method="get">
    <input type="submit" value="Go To Other Page"/>
    </form>

    <form action="test2.html" method="get">
    <input type="submit" value="Go To Other Other Page"/>
    </form>

    (multiple forms on a single page is also valid HTML)


    One thing to be careful about is that you can't pass a query string in the `action' of a form. To construct a query string, you'd need to specify the parameters in the form. For instance, this:

    <form action="default.aspx?a=apple&amp;b=orange" method="get">
    <input type="submit" value="Go To Other Script Bad"/>
    </form>

    won't have the intended effect, but this will:

    <form action="default.aspx" method="get">
    <input type="hidden" name="a" value="apple">
    <input type="hidden" name="b" value="orange">
    <input type="submit" value="Go To Other Script"/>
    </form>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles