Help with Javascript Dynamic populations of fields

PeraEve
05:18:11
Help! I am trying to populate fields based on a dropdown list selection from the user. I am getting confused about how to weave javascript with PHP. This is the first time trying to do something like this. I tried to follow the example from "Dynamic population of second list box". I have provided a sample of my code. What am I doing wrong?!

function GetFieldEntry(){
<?php

echo "if (document.CMSModify.R1.value == 'Article'){";


$rsChoice = this.form.listArticles.selected;

echo "if(!empty($rsChoice)){";
include_once('../dbconnection/Connect_db2.php');
$sql = "select * from article where article_title = '$rsChoice'";
$result = mysql_query($sql);

//while ($row = mysql_fetch_array ($result))
While ($row = mysql_fetch_object($result))
{
$arttitle = $row->'article_title';
$artsubtitle = $row->'article_subtitle';
$artauthor = $row->'article_author';
$artlink = $row->'article_link';
$artimage = $row->'article_imagepath';
$artvideo = $row->'article_videopath';
$artmain = $row->'article_main';
$artcurprjt = $row->'article_currentprjt';
$arthotlink = $row->'article_hotlink';
$arttext = $row->'article_text';

echo "document.CMSModify.txtATitle.value == $arttitle;";
echo "document.CMSModify.txtASubtitle.value == $artsubtitle;";
echo "document.CMSModify.txtAAuthor.value == $artauthor;";
echo "document.CMSModify.txtALink.value == $artlink;";
echo "document.CMSModify.txtAImage.value == $artimage;";
echo "document.CMSModify.txtAVideo.value == $artvideo;";
echo "document.CMSModify.optAMTopic.value == $artmain;";
echo "document.CMSModify.optAHotLink.value == $arthotlink;";
echo "document.CMSModify.optACurPrjt.value == $artcurprjt;";
echo "document.CMSModify.tabAText.value == $arttext;";

}
mysql_close("test");
//print"<script language='JavaScript' type='text/javascript'>set_data('$state', '$city')</script>";
echo "}";
echo "}";
?>
cabalsdemon
06-08-2012
where is this

function GetFieldEntry(){

supposed to lead to

and is it in a .js file
Please Login to post your reply or start a new topic