/    Sign up×
Community /Pin to ProfileBookmark

this is driving me crazy!

Can anyone spot the bug??? Because I’ve been trying for three days and can’t. The purpose of the script is to take the ” out of a sentence and replace it with ".

<script>
function runfunction () {
var thestring = self.test.box.value;
var thestring_array = thestring.split(‘”‘);
var theresult
var counterlimit = thestring_array.length
var counter = 0
var box_value = “”
var theresult_counter

do {
theresult_counter = 0
do {
theresult[theresult_counter] = thestring_array[counter] + “&#34;”;
counter++
theresult_counter++
}
while (counter < counterlimit && theresult_counter < 2)

box_value = box_value + “document.writeln(“” + theresult[0] + theresult[1] + “”);”;
}

while (counter < counterlimit)

self.test.box2.value = box_value

}

</script>

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@CharlesFeb 14.2003 — [font=georgia]Please be more clear about what it is that you are trying to accomplish. This looks like a one line problem, but the board seems to have altrered your post.[/font]
Copy linkTweet thisAlerts:
@hungrydinoauthorFeb 14.2003 — Yes sorry - should have known. I'm trying to replace any quotation mark ( " ) with its code & # 3 4 ;

<script>

function runfunction () {

var thestring = self.test.box.value;

var thestring_array = thestring.split('"'); // this is a " between two '

var theresult

var counterlimit = thestring_array.length

var counter = 0

var box_value = ""

var theresult_counter

do {

theresult_counter = 0

do {

theresult[theresult_counter] = thestring_array[counter] + "& # 3 4 ;";

counter++

theresult_counter++

}

while (counter < counterlimit && theresult_counter < 2)



box_value = box_value + "document.writeln("" + theresult[0] + theresult[1] + "");";
}


while (counter < counterlimit)


self.test.box2.value = box_value



}

</script>
Copy linkTweet thisAlerts:
@CharlesFeb 14.2003 — [font=monospace]<script type="text/javascript">

<!--

alert('"Hello, World!"'.replace(/"/g,'&amp;#34;'))

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@hungrydinoauthorFeb 14.2003 — the html has two multiline text boxes - if i put this...

sfd " fsd " sdf

into the first text box, hit the magic button, this should pop out...

sfd & # 3 4 ; fsd & # 3 4 ; sdf & # 3 4 ;

that's without the spaces in & # 3 4 ; of course.

Right now the code adds the extra quote after the last portion but I can fix that later.
Copy linkTweet thisAlerts:
@CharlesFeb 14.2003 — [font=monospace]<script type="text/javascript">

<!--

alert('sfd " fsd " sdf'.replace(/"/g,'&#34;'))

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@hungrydinoauthorFeb 14.2003 — I'm kind of with you except for I don't know how to change it while keeping it in the variable - I tried this:

var thestring.replace(/"/g,'&#34;')

or this if that didnt show

var thestring.replace(/"/g,'& # 3 4 ;')

check out these two pages to see what I'm trying to do.

www.magictrickman.com/testing.htm

www.magictrickman.com/testing1.htm

When you copy and paste that line into the box on the first page the correct output shows up in the box below. That's the code I need to be generated from all this code. The point of writing the code for the second page was so that if a long string was entered into the first box, it could cut the code up between several document.writeln statements.

That's where the problem showed up.
×

Success!

Help @hungrydino 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.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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