www.webdeveloper.com
Results 1 to 3 of 3

Thread: How can I get two scripts to work in the head section

  1. #1
    Join Date
    Jun 2013
    Posts
    3

    How can I get two scripts to work in the head section

    <script>
    var publicationid = 1;
    function addPublication()
    {
    var obj = document.getElementById("pub");
    var data = obj.innerHTML;
    if (publicationid == 2){

    }else {

    data += "<h1 style = 'color:white;'>test</h1>";

    obj.innerHTML = data;
    publicationid++;

    <?php
    $updatePublicationsNewCounter++;
    ?>
    }
    function subtractPublication()
    {
    var obj = document.getElementById("pub");
    var data = obj.innerHTML;
    data = "" ;
    obj.innerHTML = data;
    publicationid = 1;
    <?php
    $updatePublicationsNewCounter = 1;
    ?>
    }
    </script>

    only the first one works when I take off the second one.

    How can I recopy the first script to be used again on a different div

  2. #2
    Join Date
    Jun 2013
    Posts
    3
    <script>
    <!-- javascript function to load up the new input fields -->
    var id = 1;
    function addRequirement()
    {
    var obj = document.getElementById("req");
    var data = obj.innerHTML;
    if (id == 2){

    }else {

    data += "<input class = 'editprofileinputbox' type='text' name ='requirement_new'><input class='editprofileinputbox' type ='text' name ='requirementtype_new'><br/><br/>";

    obj.innerHTML = data;
    id++;

    <?php
    $updateRequirementsNewCounter++;
    ?>
    }
    }
    function subtractRequirement()
    {
    var obj = document.getElementById("req");
    var data = obj.innerHTML;
    data = "" ;
    obj.innerHTML = data;
    id = 1;
    <?php
    $updateRequirementsNewCounter = 1;
    ?>
    }
    </script>




    </head>


    thats the actual code sorry

  3. #3
    Join Date
    Nov 2010
    Posts
    978


    what's this supposed to do:
    Code:
    var obj = document.getElementById("req");
    var data = obj.innerHTML;
    data = "" ;
    obj.innerHTML = data;
    because it looks like "get this element, copy its HTML into a variable, wipe that variable to nothing, then apply that nothing as that element's html"

    is that really what you want to do? and if so why not just
    Code:
    document.getElementById("req").innerHTML="";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles