Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:35:20+00:00 2026-06-17T18:35:20+00:00

I have a PHP echo statement in which I create an HTML button element,

  • 0

I have a PHP echo statement in which I create an HTML button element, and within that button element I’d like to set the onclick attribute to the location.href function to redirect to another page when the user clicks the button. But I can’t seem to get this working, nothing happens when the button is clicked. I think it has to do with the multitude of single and double quotes but I’m not sure. Here’s my latest attempt, but I’ve tried escaping the inner quotes a number of ways.

 echo "Commissioner Admin</th><td><button type='button' id='adddirectoradmin' value='adddirectoradmin' width='75' onclick=\"location.href('http://some-url')\">Add</button></td>";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:35:21+00:00Added an answer on June 17, 2026 at 6:35 pm

    location.href is not a function. Your quotes are all OK.

    Your problem is that you’re calling location.href instead of just assigning it a new value:

    onclick="location.href = 'http://some-url'"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following PHP echo statement: echo <td><a href='delete-news.php?deleteID=.$id. onclick='return confirm('Really delete?');'>Delete</a></td>; which is
Suppose I have a example.php file like that: <p> <?php echo _('Hello world') ?>
I have PHP scrip that goes like this: if ($cost_frm < $cost){ echo <script
I have one line in php file like this: <a class=hide-if-no-js onclick=findPosts.open( 'media[]','<?php echo
I have the dropdown list like this <?php echo $form->dropdownList($customers,'customer_name', CHtml::listData(Customers::model()->findAll(), 'id', 'customer_name'), array(
I have code like this: <?php if(isset($global_info_results)): ?> <?php echo count($global_info_results) ?> <span>Mali Oglasi:
I have quite a large IF statement which needs to update another form element
I have a file called generator.php that uses fwrite() to create a result.php on
I have a PHP if/else statement. This is the code I'm trying to echo
This is the page that uses this code. I have a php page which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.