表单传递变量,但不传递输入值

时间:2019-01-18 14:11:08

标签: php jquery html

我继承了一些损坏的代码,但是我不确定问题出在哪里。该代码是一个超链接(.control_button),可在lightbox中打开一个表单(#convert-form)。然后,它具有一个按钮(#print-button),该按钮重定向到php文件(convert-tpl.php),并传递表单中的字段。

使用XDebug,我可以看到变量'testVariable'在传递给convert-tpl.php时在$ _GET数组中,但始终将其设置为10,即使我将其更改为其他名称也是如此。我的猜测是,这是因为jQuery代码在页面加载时正在使用参数构建URL,因此它不会选择表单中的任何条目?

<div class="control_button"><a href="#convert-form" class="convert-link">Terms &amp; Conditions Print</a></div>

<div id="convert-form" style="display:none;">
            <h2>Print Terms &amp; Conditions</h2>
         <p>Fill out the form below to populate additional information in the terms and condition form. Then hit print to print a copy of the terms and conditions</p>
        <form action="phpscripts/convert.tpl" method="get" target="_blank">
            <input type="hidden" name="instructor_id" value="<?php echo $_SESSION['USER_ID']; ?>" />
            <input type="hidden" name="student_id" value="<?php echo $_GET['id']; ?>" />
            <div class="price-details left">
                <fieldset>
                    <legend>Price Details</legend>
                    <div class="input-box">
                        <label for="prices_hour">1 Hour:</label><br />
                        <input type="text" name="testVariable" value="10"/>
                    </div>
                </fieldset>
            </div>
            <div class="button-container">
                <a id="print-button" href="phpscripts/convert-tpl.php" class="big-button button-link">Print</a>
            </div>
        </form>
    </div>


    <script type="text/javascript">
    $(document).ready(function() {
        $(".convert-link").fancybox({
                maxWidth    : 800,
                maxHeight   : 600,
                fitToView   : false,
                width       : '70%',
                height      : '70%',
                autoSize    : false,
                closeClick  : false,
                openEffect  : 'none',
                closeEffect : 'none'
        });
        jQuery('#print-button').printPage({
            url: jQuery('#print-button').attr('href')+'?'+jQuery('#convert-form form').serialize()
        });
    });
    </script>   

1 个答案:

答案 0 :(得分:0)

只需执行@Sean代码:

import React, { Component } from 'react';
import MonacoEditor from 'react-monaco-editor';
import './App.css';

const code = `
import React from "react";

class App extends React.Component {
    render() {
        return (
            <span>I mean really come one</span>
        );
    }
}

export default App;
`;

class App extends Component {

  onChange = (value) => {
    console.log(value);
  }

  editorDidMount = (editor, monaco) => {
    console.log('editorDidMount', editor);
    editor.focus();
  }

  render() {
    const options = {
      selectOnLineNumbers: true
    };
    return (
      <div className="App">
        <MonacoEditor
          height="600"
          width="600"
          language="javascript"
          theme="vs-dark"
          value={code}
          onChange={this.onChange}
          editorDidMount={this.editorDidMount}
        />
      </div>
    );
  }
}

export default App;