geds13
geds13

Reputation: 191

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.

Upvotes: 2

Views: 2941

Answers (1)

dfsq
dfsq

Reputation: 193261

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>

Upvotes: 2

Related Questions