0

美好生活的朋友们,我不知道如何用这个文本区域更新数据库。有人可以帮忙吗?

ajax 调用

$$('.btn').addEvent('click', function() {
var request = new Request( {
                        url: '<?php echo $baselink;?>',
                        method: 'post',
                        onSuccess:function(responseText) { alert(responseText);},
                        data: {                    
                        'name' : this.id,
                        'value' : this.value,
                        'tmpl':'component',
                        'format':'raw',
                        'ajax' : 1
                        }
}).send();});


**//Form//**
$s6=$item['Select6'];
$id=$item['items_id'];
print '<form method="post" class="formulier">
<input maxlength="250" NAME="name" class="name" id="'.$id.'" value="'.$s6.'" SIZE="50">
<input type="submit" value="Click me" class="btn"/></form>';

询问

if(JRequest::getVar('ajax') ) {  
$state=JRequest::getInt('value','oeps');    
$id=JRequest::getVar('name','');   
if ( $id ) {  
$state=(int)$state;  
$query="UPDATE #__dataitems set `Select6`='".$state."' where `items_id`=".$id;    
$db->query();
echo ' Bijgwerkt naar '.$state.' '.$id;
exit;}
4

1 回答 1

0

You are currently listening on the radio button click and send the event when it does.

You need to add a button/href to your form and bind an click event to it, and then once it is clicked, just collect the data from the radio button and the textarea and send it:

HTML:

<input type="button" value="Click me" class="btn"/>

JS:

$$('.btn').addEvent('click', function(){
var radioId = ...//get radio id
var radioVal = ...//get val
var textarea = ... //get textarea val
var request = new Request( {
                            url: '<?php echo $baselink;?>',
                            method: 'post',
                            onSuccess:function(responseText) { alert(responseText);},
                            data: {
                            'volgorde' : radioId,
                            'check' : radioVal,
                            'textarea' : textarea ,
                            'tmpl':'component',
                            'format':'raw',
                            'ajax' : 1
                            }
    }).send();});

I'm guessing you are using prototypejs (because of the $$), i don't know it very well so i can't help you with how to get the elements id and values, but this is the direction.

于 2012-08-07T10:05:17.517 回答