/    Sign up×
Community /Pin to ProfileBookmark

dynamic textbox

Hi how can I change the below code to fill an input textbox instead of a select menu based on the value that is selected from the first menu

[code=html]

<form name=”classic”>
<select name=”countries” onchange=”updatecities(this.selectedIndex)” style=”width: 150px”>
<option value=”home”>Home Phone</option>
<option value=”cell”>Cell Phone</option>
<option value=”work”>Work Phone</option>
<option value=”all”>All Phone</option>
</select>
<select name=”cities” style=”width: 150px” onClick=”alert(this.options[this.options.selectedIndex].value)”>
</select>
</form>

<script type=”text/javascript”>

var countrieslist=document.classic.countries
var citieslist=document.classic.cities

var cities=new Array()
cities[0]=””
cities[1]=[“<?php echo $_SESSION[‘home_phone’]; ?>|<?php echo $_SESSION[‘home_phone’]; ?>”]
cities[2]=[“Vancouver|vancouvervalue”, “Tonronto|torontovalue”, “Montreal|montrealvalue”, “Calgary|calgaryvalue”]
cities[3]=[“London|londonvalue”, “Glasgow|glasgowsvalue”, “Manchester|manchestervalue”, “Edinburgh|edinburghvalue”, “Birmingham|birminghamvalue”]

function updatecities(selectedcitygroup){
citieslist.options.length=0
if (selectedcitygroup>0){
for (i=0; i<cities[selectedcitygroup].length; i++)
citieslist.options[citieslist.options.length]=new Option(cities[selectedcitygroup][i].split(“|”)[0], cities[selectedcitygroup][i].split(“|”)[1])
}
}

</script>
[/code]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

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