views:

90

answers:

3

MAIN WINDOW

// some javascript
//some html
//here ajax-call to load all divs
//all divs hidden by default
//based on user choice(from select option), show selected group of divs
//click any shown div to call corresponding popup

POPUP WINDOW

//edit contents of that div.
//on close i need
1. refresh main window to load all divs
2. select the previously selected user option(from select option)
3. show corresponding divs only
4. most important is i have to give the user the main page,
   where they clicked the div before(not the page starting always!)

I tried and i am left with " $ not found error ". any ideas..? suggestions?

this is the main window

     <script type="text/javascript" src="jquerymin.js"></script>
        <script type="text/javascript">
        var visible_status=0;
        function selectFn(sno){
        if(sno==1){
                $('#id2').hide();
                $('#id1').show();
                visible_status=1;
        }else if(sno==2){
                $('#id2').show();
                $('#id1').show();
                visible_status=2;
        }
        }

        function popitup(url) {
            newwindow=window.open(url+'?parent_status='+visible_status,'name');
            if (window.focus) {newwindow.focus();}
                return false;
        }
        </script>
        <select name='optionw' 
        onchange="selectFn(this.options[this.selectedIndex].value);">
        <option value="">Select</option>
        <option value="1">Div1</option>
        <option value="2">All</option>
        </select>
        <div id='id1' style="display:none;">DIV1</div><!--by ajax i am loading-->
        <div id='id2' style="display:none;">DIV2</div><!--these divs-->
        <button onclick="popitup('popup.php');">popUp</button><br><!--and these-->

popupwindow

<script type="text/javascript" src="jquerymin.js"></script>
    <script type="text/javascript">
    var parent_status='<? echo $_GET[parent_status];?>';

    function closePopup() {
        window.opener.history.go(0);
        //alert('going to call parent selectFn('+parent_status+')');
        window.opener.selectFn(parent_status);
        self.close();
    }
    </script>

...Here  editing a part of the main page content...
<input type=button value=close_popup onclick="closePopup();">

If i remove the comments in the closePopup function , it works as expected. Any help to make it work without commnted line.

+2  A: 

I would suggest that perhaps you're not linking to the jQuery library properly or have it linked in the wrong order. Could you provide more details as to what you're asking? Do you want the code to do this, or are you just asking about the jQuery object not being found?

Jay
@jay I edited the question by including codes. i want to know where i am wrong?
Kumar
@jay thanks for your try. I have no problem with double-quote in GET,its working fine. if i removed the comment in closePopup function , everything ok. But that alert is a noise for the user, so i want to remove it.
Kumar
@kk So what you're saying is that if you have the alert in there, everything works fine, and all the variables are correct. If you remove the alert suddenly you get the "$ not found error"?
Jay
@jay yes .....exactly.
Kumar
+1  A: 

get firebug plugin for firefox. load your page .. go to firebug console .. type $ and if it doesnt say 'function()' you haven't included the jQuery library properly

Scott Evernden
thanks for this new testing idea.
Kumar
A: 

I'm trying to understand your question; it's very unclear what you're describing. Is the code you're showing coming from your web browser once you've loaded it (by viewing the source) or is it prior to being evaluated on the server?

What happens if you change this line in the popup:

var parent_status='<? echo $_GET[parent_status];?>';

to this:

var parent_status=1;

Jonathon
I'm currently trying to understand the question also, but as far as I can work out it works perfectly if the javascript pauses for the alert, otherwise it throws the mentioned error.
Jay
@Jay that's what it seems like he's saying, but it doesn't look like he's got some odd timing issue going on with the code he's showing.
Jonathon
@jay thanks for teting it, and commented.
Kumar
@kk Have you tried changing the line I mentioned to see what happens?
Jonathon
@jon same output. There is nothing wrong in the '<? echo $_GET[parent_status];?>' statement. my problem is with parent window reload, i think.
Kumar