0

Need someone to help me on the jQuery Dialog plugin by Eric Martin - Simple Model

I have a PHP page that contains the link that I want to pass a value to another page. Thus, I need help on how to pass the value to the jQuery script that contain the var for the page URL below?

Profile.php

<div id='basic-modal'>
       <a href='#' class='basic'>Jquery Dialog Demo</a>
</div>

Note: When I click on the link, it will call the jQuery basic-model div from Basic.js

Basic.js

jQuery(function ($) {

    // Load dialog on click
    $('#basic-modal .basic').click(function (e) {

    // Display an external page using an iframe
var src = "http://365.ericmmartin.com/";
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
    closeHTML:"",
    containerCss:{
        backgroundColor:"#fff",
        borderColor:"#fff",
        height:450,
        padding:0,
        width:830
    },
    overlayClose:true
});

        return false;
    });
});

Note: On the above, I want the var src contain variable value that I should pass it from the Profile.php instead. How should I do this?

5
  • You question is unclear. Show the code that contain the value you want to pass Commented Dec 21, 2011 at 5:23
  • Hi Chibuzo, thanks for the reply. Here's the example of the page link variable that I want to pass to the Basic.js => domain.com/Poll.php?id=1&validate=yes Commented Dec 21, 2011 at 5:27
  • Hi Chibuzo, Basically, the Profile.php should looks like this: <div id='basic-modal'> <a href='localhost/Poll.php?id=1&validate=yes' class='basic'>Jquery Dialog Demo</a> Vice versa, on the Basic.js, the var src should contain the link from the Profile.php instead. Please advice and thanks </div> Commented Dec 21, 2011 at 5:31
  • @user1109161 your requirement is once click on link in profile.php it will redirect to poll.php, before redirection you want to pass the id and validate to basic.js, Am i correct? Commented Dec 21, 2011 at 5:40
  • Hi Chibuzo, Robin Michael Poothurai, thanks for the replies as i managed to get it sorted from the 2 answers below by Jake Feasel and Fenec. Against, much appreciated and thanks for the valuable feedbacks. Cheers Commented Dec 21, 2011 at 5:47

2 Answers 2

2

Change Profile.php slightly:

<div id='basic-modal'>
       <a href='http://localhost/Poll.php?id=1&validate=yes' class='basic'>Jquery Dialog Demo</a>
</div>

Change Basic.js like so:

    jQuery(function ($) {

        // Load dialog on click
        $('#basic-modal .basic').click(function (e) {
        e.preventDefault();

        // Display an external page using an iframe
        var src = $(this).attr('href');
        $.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
            closeHTML:"",
            containerCss:{
                backgroundColor:"#fff",
                borderColor:"#fff",
                height:450,
                padding:0,
                width:830
            },
            overlayClose:true
        });


            return false; // not sure why you're doing this
        }); // end of click handler




    });  // end of document.ready
Sign up to request clarification or add additional context in comments.

3 Comments

Hi Jake, THANKS the code and showing me the right direction. It works now. Much appreciated!
Looks like you got it. You might want to vote up Fenec's answer too - that is a more tangible way to show your appreciation.
Jake, i tried to vote up on Fenec's thread, but the system seems returned me error said "Vote Up requirers 15 reputation" .. So, am not able to do it.
1
e.preventDefault();
var src = $(e.target).attr("href");

2 Comments

Hi Fenec, THANKS for the code. It works now. Much appreciated!
Hi Fenec, tried to vote up on this thread but the system returned me the following error "Vote Up requirers 15 reputation". Thus, am not able to do it but really appreciate your help.

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.