using the code below, im trying to populate the textfield and the
textarea with data stored in my db.

HTML PAGE:
<head>
        <script src="../js/jquery-1.1.3.1.pack.js" type="text/javascript"></
script>
        <script type="text/javascript">
                 $(document).ready(function(){
                  $("#editNewsItem").change( function()
                        {
                                var newsId = $("#editNewsItem").attr("value");
                                
$("textarea#title").load("processing.php",{theId:newsId});
                                
$("textarea#article").load("processing.php",{theId:newsId});

                        });
                 });

        </script>
</head>

<form action="processing.php" method="post">


<select name='news' id='editNewsItem' name='editNewsItem'>
<option value="1">one</option>
<option value="2">two</option>
</select>

<input type="submit" value="submit" id="" name="editNewsSubmit"/>
<input type="text" id='title' />
<textarea id='article' cols='20' rows='20'></textarea>

PROCESSING.PHP

include ('../inc/db.inc.php');

        $newsId = $_POST['theId'];

        $query = "select title from news where news.id = $newsId";
        $result = mysql_query($query) or die ('problem!');
        $newsRow = mysql_fetch_array($result,MYSQL_ASSOC);
        extract ($newsRow);
        echo $newsRow['title'];

        $query2 = "select article from news where news.id = $newsId";
        $result2 = mysql_query($query2) or die ('problem2');
        $newsRow2 = mysql_fetch_array($result2,MYSQL_ASSOC);
        echo $newsRow2['article'];

the result is that when i change the select menu, the correct data
gets returned but both the title and the article text appear in the
textarea. how can i get the title (from $query) to appear in the text
field and the article (from $query2) to appear in the textarea?

id also like to use a callback to insert a <span>Success!<span> into
the DOM.

many thanks for any pointers,
stef

ps - the title is just text but the article is html (stored in the db
as html generated by tinymce)

Reply via email to