0

i need to pass a variable called 'test_var' to my dialog box but i don't know how to do that

how can i pass variable from my function that calls the dialog box to dialog box ?

    //a tag calls to starter function and sends variable as parameter

        <a href="#" onclick="starter(test_var)"> go </a>
    //starter func recives the test_var and calls the dialog box 
//what i want is to somehow send test_var to dialogbox in here


            function starter(test_var){

           //some stuff 

            $('#dialog_div').dialog('open');
            return false;
            }
            }


            $('#dialog_div').dialog({
            aoutoOpen:false,
            with:600,
            buttons:{
            "ok":function(){

    // i want to be able to alert test_var in here 
            alert(test_var)
            }
            }
            })

        }

i've tried

function starter(test_var){

       //some stuff 

        $('#dialog_div').dialog('open' , test_Val);
        return false;
        }
and

$('#dialog_div').dialog(test_val , {//coode
})

but it doesn't work

7
  • What do you want to do with the variable? Commented Sep 13, 2011 at 13:41
  • i want to send it to another page by ajax but firs i need user comment and confirmation thats why i need a dialog box Commented Sep 13, 2011 at 13:49
  • Do you need to use the variable as part of the display in the dialog box? Where's the variable coming from? Commented Sep 13, 2011 at 13:51
  • no i just want to send it to another page , it's a parameter from my first function (starter()) Commented Sep 13, 2011 at 13:57
  • Then you don't need to pass it to the dialog box, just use it in your ajax call. Commented Sep 13, 2011 at 13:59

1 Answer 1

2

Just make it a top level variable and then the dialog will have direct access to it.

Sign up to request clarification or add additional context in comments.

Comments

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.