gpt4 book ai didi

php - 从 TextArea 检索文本!

转载 作者:行者123 更新时间:2023-11-28 03:00:44 25 4
gpt4 key购买 nike

再次您好,感谢您的努力!由于我之前的问题没有成功,我想我应该给它另一种方法。所以基本的想法是更新 mysql 上的日历事件:

$eventQuery = mysql_query("SELECT id, body FROM tblCalEvent WHERE id= '$eid'", $conn);

它单独位于 PHP 文件上,通过返回 ID 和 Body 可以正常工作。现在,我需要将正文显示在此表单的文本区域中(该表单位于包含所有 JavaScript 函数的主页上):

 <div style="display: none; margin-top: 10px;" id="editEvent">      
<br>
<textarea id="evtBody" cols="20" rows="5" wrap="hard"></textarea>
<br>
<input type="button" value="save changes" onClick="updateEvent(($F('eid'),$F('evtDay'));">
<input type="button" value="Cancel" onClick="Element.hide('editEvent');">

当我调用这个函数时:

function editEvent(eid, body) {

if(Element.visible('editEvent')) {
// do nothing, its already visble.
} else {
setTimeout("Element.show('editEvent')", 300);
}
}

然后,表单通过传递之前的 eid 和编辑后的正文来调用下面的函数:

function updateEvent(eid, body) {

new Ajax.Updater('editEvent','rpc.php', {method: 'post', postBody: 'action=updateEvent&&eid='+eid+'&body='+body+'', onSuccess: Element.hide('editEvent')});

if(Element.visible('editEvent')) {
Element.hide('editEvent');
} else {
setTimeout("Element.show('editEvent')", 300);
}
}

非常感谢您的建议!以下是我尝试失败的方法!

大家好,提前感谢您的帮助!这真让我抓狂!我想做的是通过编辑 PHP 文件中此表单中回显的文本来编辑日历上的事件:

echo '<div style="background-color: white; margin-bottom: 4px; padding: 1px;" id="event_'.$e_id.'">
<textarea id="evtBody" cols="20" rows="5" wrap="hard"> '. nl2br($e_body) .'/textarea>
<input name="save" id = "save" type="button" value="Save" style="height:1.8em;width:3.5em;" onClick="updateEvent(('.$e_id.'), $F(\'evtBody\'))"/>

除了最后一部分 $F(\'evtBody\') 之外,一切正常,其中函数返回一个空字符串,这在我的数据库中是不允许的。

这是我当前的功能:

function updateEvent(eid, body) {

alert(eid);// returns the Event ID correctly
alert(body);// returns an empty string instead of text in the text area

new Ajax.Updater('editEvent','rpc.php', {method: 'post', postBody: 'action=updateEvent&&eid='+eid+'&body='+body+'', onSuccess: Element.hide('editEvent')});

if(Element.visible('editEvent')) {
Element.hide('editEvent');
} else {
setTimeout("Element.show('editEvent')", 300);
}
}

最佳答案

您没有正确使用 $F() 函数。请参阅this Prototype page 。您应该将一个元素传递给 $F() 但您传递的是一个 ID。所以,而不是这个:

$F('evtBody')

你应该使用这个:

$F($('evtBody'))

关于php - 从 TextArea 检索文本!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1071378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com