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 8063851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:10:44+00:00 2026-06-05T11:10:44+00:00

I have a simple dialog box that pops up when I hit a sample

  • 0

I have a simple dialog box that pops up when I hit a sample link button on my page. What I want to do is change the onclick jquery function from the link to one of my buttons in my table. The buttons currently direct the web browser to a new page, but I want them to open the dailog box with thier corresponding view file in it. I am using CakePHP 2.x.
I looked into using href but Im not sure how to go about that.

Here is the code for my index.ctp file where the buttons are located.

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/start/jquery-ui.css" type="text/css" media="all" />

<a href="#">link</a>   <!-- this is to test if the dialog box works -->
<div id="dialog"></div>

<script>
var p = '<p>test test test test test test</p>';
$('#viewButton').click(function()
{
//  $(location).attr('href', 'view.ctp');  // not sure if this line of code is on the right track or not
    $(p).dialog(
    {
        width: 400,
        height: 400,
        modal: true,
        resizable: true,
        buttons:{
            OK: function(){
                $(this).dialog("close");}}
    });
})
</script>

<p><marquee><u>Local Clocks</u></marquee></p>

<table>
    <thead><tr>
        <th>Id</th>
        <th>Name</th>
        <th>Actions</th>
    </tr></thead>
<tbody>

<?php 
foreach($localClocks as $LocalClock) { ?>

<tr>
    <!-- <td><?php //echo $LocalClock['LocalClock']['id']; ?></td> -->
    <td><?php echo $this->Html->link($LocalClock['LocalClock']['id'], array('controller'=>'localClocks', 
    'action'=>'view', $LocalClock['LocalClock']['id'])); ?></td> 

    <td><?php echo $LocalClock['LocalClock']['name']; ?></td>

<td><input type="button" class="viewButton" value="View" onclick="location.href='<?php echo $this->Html->url(array('controller' => 'localClocks', 'action' => 'view', $LocalClock['LocalClock']['id'])); ?>';"/>
<input type="button" class="editButton" value="Edit" onclick="location.href='<?php echo $this->Html->url(array('controller' => 'localClocks', 'action' => 'edit', $LocalClock['LocalClock']['id'])); ?>';"/>
    </td>
</tr>

<?php } ?>

</tbody>
</table>

I need help with switching the button onclick events to opening the dialog box and have the dialog box display the respective View pages.

Thanks in advance

  • 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-05T11:10:45+00:00Added an answer on June 5, 2026 at 11:10 am

    Here is how I was able to accomplish this. I hope it helps others.

    First add blank div’s into the index page with an id.

    <div id="view_dialog"></div>
    

    Then, using jQuery, create a function to create a dialog out of that div.

        <script>
    $(function()
    {
        var $dialog = $("#view_dialog").dialog(
            {
                autoOpen: false,
                title: 'View Local Clock',
                height: 200,
                width: 1200,
                resizable: true,
                modal: true,
                buttons:
                {
                    "Ok": function()
                    {
                        $(this).dialog("close");
                    }
                }
            });
        $(".view_dialog").click(function()
        {
            $dialog.load($(this).attr('href'), function ()
                    {
                        $dialog.dialog('open');
                    });
            return false;
        });
    });
    </script>
    

    And, lastly, create the button/link.

    <?php echo $this->Html->link('View', array('action' => 'view', $LocalClock['LocalClock']['id']), array('class' => 'view_dialog')); ?>
    

    This code allowed me to have a dialog box open when I clicked on the view link that shows the specific info for that item in the dialog box.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Jquery dialog box, that dialog contains a button which sends
I have a simple jQuery dialog box that has an html input inside it.
I have written a simple jQuery dialog box that will appear in an asp
I have a div, divDialog, that contains a simple dialog box. It begins life
I have some simple jQuery that renders a page in my Rails app. Here's
I have a v simple dialog box that I would like to display as
I have a list a simple dialog box which contains a few checkboxes, I
I have a simple wordpress/php landing page with a click-to-call link: <a href=tel:888-555-7777 target=_self>888-555-7777</a>
I have a simple ScrollView in a layout that displays an About Box in
I have a simple little dialog that lets user setup a time block. The

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.