gpt4 book ai didi

javascript - AJAX - 如何在弹出菜单中运行脚本

转载 作者:行者123 更新时间:2023-12-03 11:36:37 26 4
gpt4 key购买 nike

我现在有一个弹出菜单,可以打开并显示文本。我想要的是能够将 Controller 附加到弹出菜单。例如:我希望显示一个编辑配置文件弹出窗口,其中包含编辑配置文件所需的所有输入。

userprofile_view.php:

        <div class="upload">
<?php
$data = array('id' => 'test');
echo form_open('', $data);
echo form_submit('upload', 'Upload');
echo form_close();
?>
</div>
<div id="popupbox">
<center>
<p class="head">Terms and Conditions</p>

<p class="term_full">By entering your email, you allow Musiclear to send you information regarding Musiclear and
related services <br><br> By entering your email, you also understand that you can break our hearts and unsubscribe
at anypoint. <br><br> And feel free kick us if we ever share your email address (you can trust us)</p>
</center>

</div>

这是按钮和弹出表单后面的 html。

main.js:

$( "#test" ).submit(function( event ) {
event.preventDefault();
document.getElementById('popupbox').style.visibility="visible";
});

在按钮上单击“我使表单可见”。

如何在弹出菜单中使用表单来实现此功能?

编辑:

上传 Controller (我想在弹出窗口中显示的内容):

function do_upload_profilepicture()
{

$this->load->model('model_users');
$userID = $this->model_users->getUserID($this->session->userdata('username'));

$config['upload_path'] = './img/profilepictures/';
$config['allowed_types'] = 'jpg|png';
$config['overwrite'] = TRUE;
$config['file_name'] = $userID;
$config['max_size'] = '500';
$config['max_width'] = '1920';
$config['max_height'] = '1028';

$this->load->library('upload', $config);


if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());

$this->load->view('upload_profilepic_form', $error);
}
else
{
$upload_data = $this->upload->data();

$resize['image_library'] = 'gd2';
$resize['source_image'] = $upload_data['full_path'];
$resize['maintain_ratio'] = FALSE;
$resize['width'] = 180;
$resize['height'] = 180;

$this->load->library('image_lib', $resize);
$this->image_lib->resize();
$this->image_lib->clear();
$this->model_users->setProfilePic($userID, $upload_data['orig_name']);


$this->create_thumb($upload_data['orig_name']);
redirect('userprofile/home/' . $userID);


}
}

userprofile_view.php(弹出框):

        <div id="popupbox">     
<?php echo form_open_multipart('upload/do_upload_profilepicture');?>


<input type="file" name="userfile" size="20" />

<br /><br />

<input type="submit" value="upload" />

</form>

</div>

最佳答案

将函数调用放在脚本标签内 -

<div id="popupbox">

<?php
echo '<script type="text/javascript">';
echo "form_open_multipart('upload/do_upload_profilepicture');";
echo '</script>';
?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
</div>

关于javascript - AJAX - 如何在弹出菜单中运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26469996/

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