0

I'm having problem in getting the value from a pop up window frame to a normal window combobox. In the pop up window i've tried to get the value from a php table using a link. I dont no if its the frame which is causing problem or the code... can u help me plz..

The combobox where the value will be input after onClick Select

search page

function getScriptPage(div_id,content_id,get_count) { subject_id = div_id; content = document.getElementById(content_id).value; http.open("GET", "script_page.php?content=" + escape(content)+"&count="+get_count, true); http.onreadystatechange = handleHttpResponse; http.send(null); } $('#select .coursetable a.principal').click(function(e){ var text = $(this).parent().prev().prev().prev().prev().prev().text(); $('ui-autocomplete-input').val(text); });

<span class="textb">Enter Search Keyword here :</span>
<input type="text" id="text_content" size="30" onKeyUp="getScriptPage('count_display','text_content','1')">
<input type="button" class="login" value="Search" onMouseUp="getScriptPage('output_div','text_content','0')">
    <div id="count_display">

    </div>


<div id="output_div">

</div>
</form>

script page

include('config.php');

$strlen = strlen($_GET['content']);
$display_count = $_GET['count'];

$select = "select * from course where course_name like '%".$_GET['content']."%' or  course_type like '%".$_GET['content']."%' or duration like '%".$_GET['content']."%' or step_id like '%".$_GET['content']."%'";
$res = mysql_query($select);
$rec_count = mysql_num_rows($res);
if($display_count)
{
  echo "There are <font color='red' size='3'>".$rec_count."</font> matching records found.Click Search to view result.";
}
else
{

?>
Search Result name course type description duration step_id

if($rec_count > 0)
{
    while($data=mysql_fetch_array($res))

    {
        echo "<tbody>

        <tr>
              <td class='principal'>".$data['course_name']."</td>
              <td class='principal'>".$data['course_type']."</td>
              <td class='principal'>".$data['description']."</td>
              <td class='principal'>".$data['duration']."</td>
              <td class='principal'>".$data['step_id']."</td>

            <td>" .'<a href="" id="select" class="lien2" name="select" value="'.$data['course_name'].'" >Select</a>' ."

             </tr>
            </tbody>";
    }
}
else
    echo '<td colspan="5" align="center"><FONT SIZE="2" COLOR="red">No matching records found....!</FONT></td>';

} ?>

i've tried the following javascript code in the search page, but still not working

$('#output_div .coursetable a.principal').click(function(e){ var text = $(this).parent().prev().prev().prev().prev().prev().text(); $('ui-autocomplete-input').val(text); });

or

$('#select .coursetable a').bind('click', function(event) { var text = $(this).parent().prev().prev().prev().prev().prev().text(); $('ui-autocomplete-input').val(text); });

can you help me plz...

Thx regards

3
  • Does it have to be a pop up windows feels sick, why not a jQuery lightbox style pop up? That'll make it easier to code and better for the UX Commented Jan 7, 2011 at 8:49
  • 1
    This kind of JavaScript code "parent().prev().prev().prev().prev().prev().text();" makes me sick Commented Jan 7, 2011 at 8:56
  • @jakenoble : is it possible to include php files on lightbox or only for images?? Commented Jan 7, 2011 at 9:56

1 Answer 1

0

My honest opinion is not to use a pop up window, but to use something that is better for the user and easier to maintain, no one likes to see .prev() multiple times.

You can use a plug in for jQuery like Boxy which can load a page via Ajax, or it can simply load a predefined form into the lightbox window. This form can then be sumbitted via convention means, or via Ajax.

Boxy provides functions for various events, e.g. what happens when the window is closed, forcing the window to close etc.

Once the form is submitted via Ajax you can then force the window to close if the Ajax response was successful.

Hope that helps.

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

3 Comments

hello was just checking the boxy... thx man... one question, can i implement a search on it and do wat i wanted to do????
Define search, a form, the results ... ?
I cannot answer because I do not know what you mean by search. You can use Boxy to load the results or the search form or both.

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.