Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery将href值输入span应答器_Javascript_Jquery_Html_Href - Fatal编程技术网

Javascript Jquery将href值输入span应答器

Javascript Jquery将href值输入span应答器,javascript,jquery,html,href,Javascript,Jquery,Html,Href,我需要像这样将href值输入span应答器 <p class="name"> <a download="adja-lo.pdf" title="adja-lo.pdf" href="http://localhost/MatrixDRSnews/apps/Matrix/server/php/files/adja-lo.pdf">adja-lo.pdf</a> </p> 好的,我使用jquery上传插件,所以我想在我的数据库中插入一些信息

我需要像这样将
href
值输入span应答器

<p class="name">
    <a download="adja-lo.pdf" title="adja-lo.pdf" href="http://localhost/MatrixDRSnews/apps/Matrix/server/php/files/adja-lo.pdf">adja-lo.pdf</a>
</p>


好的,我使用jquery上传插件,所以我想在我的数据库中插入一些信息:2个隐藏输入、文本区域、输入、文本、文件名和url

 <div id="Form" class="container1" style="display: none; width: 850px; height: 500px;">
        <form id="fileupload"  method="POST" enctype="multipart/form-data">
            <span class='span' id=txt_lala></span>
            <input type="hidden" name="anomalie" class="hide" id="anomalie" value="">
            <input type="hidden" name="missionID" class="hide" id="missionID" value="<?php echo $_SESSION['mission_id']?>">
            <fieldset class="fieldset1">
                <table class="myTable" id="myTable">

                <!--<input type="text" name="fait" id="fait" value="" class="text ui-widget-content ui-corner-all">!-->
                <tr>
                   <td><label for="name">Recommandation:</label></td>
                    <td><textarea name="recommandation" id="recommandation" cols="50" ></textarea></td>

                </tr><br>
                    <tr>
                        <td><label for="name">Constat:</label></td>

                        <td><textarea name="fait" id="fait" cols="50" ></textarea></td>
                    </tr>
                </table><br>

                <!-- Redirect browsers with JavaScript disabled to the origin page -->
                <noscript><input type="hidden" name="redirect" value="https://blueimp.github.io/jQuery-File-Upload/"></noscript>
                <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
                <div class="fileupload-buttonbar">
                    <div class="fileupload-buttons">
                        <!-- The fileinput-button span is used to style the file input field as button -->
            <span class="fileinput-button">
                <span>Add files...</span>
                <input type="file" name="files[]"  multiple>
            </span>
                        <button type="submit" class="start" >Start upload</button>
                        <button type="reset" class="cancel" >Cancel upload</button>
                        <button type="button" class="delete">Delete</button>
                        <input type="checkbox" class="toggle">
                        <!-- The global file processing state -->
                        <span class="fileupload-process"></span>
                    </div>
                    <!-- The global progress state -->
                    <div class="fileupload-progress fade" style="display:none">
                        <!-- The global progress bar -->
                        <div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div>
                        <!-- The extended global progress state -->
                        <div class="progress-extended">&nbsp;</div>
                    </div>
                </div>
                <!-- The table listing the files available for upload/download -->
                <table role="presentation"><tbody class="files"></tbody></table>
            </fieldset>
            <script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-upload fade">
        <td>
            <span class="preview"></span>
        </td>
        <td>
            <p class="name">{%=file.name%}</p>
            <strong class="error"></strong>
        </td>
        <td>
            <p class="size">Processing...</p>
            <div class="progress"></div>
        </td>
        <td>
            {% if (!i && !o.options.autoUpload) { %}
                <button class="start" disabled>Start</button>
            {% } %}
            {% if (!i) { %}
                <button class="cancel">Cancel</button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
            <!-- The template to display files available for download -->
            <script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-download fade">
        <td>
            <span class="preview">
                {% if (file.thumbnailUrl) { %}
                    <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
                {% } %}
            </span>
        </td>
        <td>
            <p class="name">
                <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
            </p>
            {% if (file.error) { %}
                <div><span class="error">Error</span> {%=file.error%}</div>
            {% } %}
        </td>
        <td>
            <span class="size">{%=o.formatFileSize(file.size)%}</span>
        </td>
        <td>
            <button class="delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>Delete</button>
            <input type="checkbox" name="delete" value="1" class="toggle">
        </td>
    </tr>
{% } %}
</script>
        </form> 


首先,通过简单的研究,自己动手做一些工作。你尝试过什么?你的问题中没有jQuery代码显示你的方法是什么,HTML中也没有
span
元素。很抱歉,这不是span元素,而是p元素
    jObjFormulaire.on( "submit", function(){

                var fait = $( "#fait" ).val(),
                    anomalie = $( "#anomalie" ).val(),
                    missionID = $( "#missionID" ).val(),
                recommandation =$( "#recommandation" ).val();
                /*var element = $("#pnewanomalie");
                alert(element);*/
                var filedata = document.getElementsByName("name");
                var i = 0, len = filedata.files.length;

// On file add assigning the name of that file to the variable to pass to the web service

                var aa = $("#new_anomalie");
               // alert(aa.length);
                if(aa.length){
                   // alert('autreAnomalie');
                    if($("#new_anomalie").val()!=''){
                    var autreAnomalie = $("#new_anomalie").val();
                        var status = 'NEW';
                       // alert(autreAnomalie);
                    }else{
                        var autreAnomalie ='';
                        alert( "Veuillez donner le nom de la nouvelle anomalie." );

                    }


                }

                if ( fait == '' ){

                    alert( "Champs commentaire Obligatoire ! Soumission du formulaire annulée." );

                    $( jObjFormulaire.data( "checkbox" ) ).prop( "checked", false );
                    jObjFormDiv.dialog( "close" );

                } else {

                    $.post("<?php echo $_SESSION['config']['businessappurl']?>index.php?display=true&module=Inspecteur&page=insertanomalie", {
                        fait1: fait,
                        anomalie1: anomalie,
                        missionID1: missionID,
                        autreAnomalie1:autreAnomalie,
                        status:status,
                        recommandation : recommandation

                    }, function(data) {
                       // $('#recommandation').val(data);
                        alert(data);
                        removeTableRow($("#myTable"));
                        $('#form')[0].reset(); // To reset form fields
                        location.reload();
                       // window.location.reload(true);
                       // $("#content").load('<?php echo $_SESSION['config']['businessappurl']?>index.php?display=true&module=Inspecteur&page=traitervolet&volet_id=<?php  echo $_GET['volet_id']?>');
                       // $('#content').html(data);
                    });

                    //this.reset(); // To reset form fields

                    /*
                     * Comme le changement d'avis de l'utilisateur n'est pas géré,
                     * on peut l'empêcher de changer d'avis, mais ce n'est pas une bonne solution.
                     */
                    $( "#pnewanomalie" ).remove();
                    $( jObjFormulaire.data( "checkbox" ) ).prop( "checked", true );


                    jObjFormDiv.dialog( "close" );
                }

                // Il faut bloquer la soumission traditionnelle
                // du formulaire sinon la page est rechargée !
                return false; // important !
            });