简体   繁体   中英

passing URL parameters using buttons

how do i use the onclick function when using parameters or is there any other alternative, before i was using anchor links which works but now since i changed it to input type button, instead of just button and using anchor links, it wont work it clicks but not redirecting.

here is an example of my button

echo "<input type='button' class='btn btn-success' onclick='window.location='../../includes/userordersummary.php?orderid=".$row['orderid']."&serial=".$row['serial']."'' value='View Order'>";

please note that i am using echo.

1). Escaping . You need to escape this part:

onclick='window.location=\'../../include .... "\'' value='View Order'>";
                         ^--- here              ^-- and here

2).Button styles . Also

before i was using anchor links which works but now since i changed it to input type button

you can still use links but make them look like buttons with the same bootstrap classes

<a class="btn btn-success">...</a>

3). Confirmation . If you want to add a confirmation before redirecting you can make use of confirm dialog:

<a onclick="return confirm('Are you sure?')" href="...">click</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM