/    Sign up×
Community /Pin to ProfileBookmark

Help me to convert this code in PHP

I am a beginner in developing a site just though someone help me to convert this javascript to PHP, tnx?

for (i=1; i<=numQues; i++) {
correctAnswers += i + “. ” + answers[i-1] + “rn”;
}
form.solutions.value = correctAnswers;

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Oct 02.2007 — What do you want to do in PHP? You cannot access form elements like that using PHP because they don't exist yet. But the loop:
[code=php]
for ($i=1; $i<=$numQues; ++$i) {
$correctAnswers += i.". ".$answers[$i-1]."rn";
}[/code]
Copy linkTweet thisAlerts:
@vax90authorOct 03.2007 — actually sir the variable "correctanswer" is going to pass to the HTML form

like the <textarea> so by the time it display the output by html the output is

is this

this is the variable content = " $correctAnswer="1. onr2. inr3. atr"; "

so literally the textarea automatically loop the content of the variable "correctAnswer" instead of using an array i just use a normail string variable,thank for your effort !
Copy linkTweet thisAlerts:
@MrCoderOct 03.2007 — Why build a string when you could just echo it out in to the textarea in question?
Copy linkTweet thisAlerts:
@Declan1991Oct 03.2007 — Actually I noticed a slight error in my code. It should be .=, not +=.
×

Success!

Help @vax90 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.18,
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,
)...