/    Sign up×
Community /Pin to ProfileBookmark

How do i a make this JS script work with PHP

Hey

How do i get this JS script to run with my PHP code.

I want the PHP code to generate the JavaScript array, but how do i do that?

[URL=”http://javascript.internet.com/forms/multi-value-drop-down-list-2.html”]http://javascript.internet.com/forms/multi-value-drop-down-list-2.html[/URL]

PHP code:

[code=php]
echo “<div style=’width: 350px; margin-top: 30px;’>”;
echo ”
<div style=’float:right; width: 150px;’>
<form>
<select name=’area’>
<option value=0>Antal personer</option>”;
for($i=1; $i<11; $i++){
echo “<option value=”.$i.”>”.$i.”</option>”;
}
echo ”
</select>
</form>
</div>”;
echo ”
<div width: 150px;’>
<form>
<select name=’area’>
<option value=’0′ selected=”selected”>Valg af disciplin</option>”;
$disciplinsQuery = dbquery(“SELECT name, id FROM disciplins”);
while($disciplinsData = dbarray($disciplinsQuery)){
echo “<option value=”.$disciplinsData[‘id’].”>”.$disciplinsData[‘name’].”</option>”;
}
echo ”
</select>
</form>
</div>”;
echo “</div>”;
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SyCoNov 11.2008 — PHP can write the page info including jS just like any other HTML or CSS. You can either build all the arrays at page load time using PHP in a jS function, then use a jS onchange event to propagate the second select. Alternatively us ajax to call the information from a table/file to fill in the second list. I'm guessing your jS is as rusty as mine was when I wanted to get into aax. If so check out xajaxproject.org. It's an ajax PHP class that's nice and easy to use. There's a forum and tutorials at the website
×

Success!

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