mwl707 Posted September 8, 2009 Share Posted September 8, 2009 Hi I am using a bit of java to prefill a comments box called 'comments' . I get the value from the code below $result = mysql_query('select * from event'); while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result, $i); $label = $meta->name ; $i++; $lcondition = "jobnumber = $importedjobnumber"; $lresult = mysql_query("SELECT * FROM event WHERE $lcondition") ; $row = mysql_fetch_array($lresult) ; $rte = $row["$label"] ; $$label = $rte ; At this point I KNOW that the variable $comments contains text. But to be double sure I do this $comments = $row['comments'] ; I have a form with a text box called comments and am using php/java to fill it echo "<script> document.form1.comments.value= '$comments' </script>" ; BUT nothing appears in the box. I have tried everything I know to get a display but nothing. Now the strange this is if i do this $comments = "this is a test" ; echo "<script> document.form1.comments.value= '$comments' </script>" ; it works !, Can anybody please tell me what I am doing wrong ? Quote Link to comment https://forums.phpfreaks.com/topic/173559-prefill-a-comments-box/ Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 Must be something wrong with your variables, because both of the echos are 100% the same. Do a var_dump($comments); and post output here. Do it before you set the test text to the variable $comments so we can see what is inside it when it does not echo the value correctly. Quote Link to comment https://forums.phpfreaks.com/topic/173559-prefill-a-comments-box/#findComment-914910 Share on other sites More sharing options...
KevinM1 Posted September 8, 2009 Share Posted September 8, 2009 Are you sure that $row['comments'] has a value? Where does $importedjobnumber come from? I'm just wondering if your second query is returning what you think it should be returning. Quote Link to comment https://forums.phpfreaks.com/topic/173559-prefill-a-comments-box/#findComment-914921 Share on other sites More sharing options...
mwl707 Posted September 8, 2009 Author Share Posted September 8, 2009 Hi I am sure that $comments has a value ; here is the dump string(50) "Do not drive on the ice road " $importedjobnumber is a $get from a previous page Quote Link to comment https://forums.phpfreaks.com/topic/173559-prefill-a-comments-box/#findComment-914967 Share on other sites More sharing options...
RichardRotterdam Posted September 8, 2009 Share Posted September 8, 2009 Java != JavaScript Is there any reason you're using Javascript? Why not simply do it all with PHP if I may ask? And what does your comment box look like in HTML? Quote Link to comment https://forums.phpfreaks.com/topic/173559-prefill-a-comments-box/#findComment-914974 Share on other sites More sharing options...
mikesta707 Posted September 8, 2009 Share Posted September 8, 2009 why not just set the value attribute with php like <input type="textbox" value="<? echo $comment; ?>" /> I know the type isn't textbox but the important part is the value part. but if you must do javascript, have you checked to see that there aren't any errors in the javascript? check your JS error logs if you have one. If your in firefox just press ctrl + shift + j Quote Link to comment https://forums.phpfreaks.com/topic/173559-prefill-a-comments-box/#findComment-914988 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.