/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KeyMaker13authorJun 29.2013 — <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
Copy linkTweet thisAlerts:
@xelawhoJun 29.2013 — ?

what's this supposed to do:
[CODE]var obj = document.getElementById("req");
var data = obj.innerHTML;
data = "" ;
obj.innerHTML = data;[/CODE]


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="";[/CODE]
×

Success!

Help @KeyMaker13 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...