2

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
  • echo is not a used in javascript or html. Are you using PHP? Commented Oct 23, 2014 at 15:21

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

1 Comment

hmm how do i add a confirmation when for example clicking the button? if i press okay then it would proceed, then if i press no, it would cancel and just refresh the page?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.