/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] auto populate a drop box

hi i am trying to populate a drop down menu from a pop up page.

what i have its working on chrome but it does not work on IE

and i was wondering if you may be able to know why.

Here is my code:

opener page

[CODE]
<form method=”post” name=”form1″ id=”form1″>
<select name=”customer_name” id=”customer_name” style=”border:1px solid black;”>
</form>
[/CODE]

second page

[CODE]
<script language=”javascript” type=”text/javascript”>
function removeAllOptions(selectbox){
var i;
for(i=selectbox.options.length-1;i>=0;i–){
selectbox.remove(i);
}
}
function addOption(selectbox,text,value ){
var optn = document.createElement(“OPTION”);
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
//opener.form1.contact.
</script>
<script language=”javascript” type=”text/javascript”>
removeAllOptions(opener.form1.customer_name)
addOption(opener.form1.customer_name,”1″,”test1″ )
addOption(opener.form1.customer_name,”2″,”test2″ )
addOption(opener.form1.customer_name,”3″,”test3″ )
addOption(opener.form1.customer_name,”4″,”test4″ )
</script>

[/CODE]

Now this works on Chrome but not ie

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 15.2010 — Referencing[CODE]<script type="text/javascript">
function removeAllOptions(selectbox){
selectbox.options.length=null; [COLOR="Green"]// simpler[/COLOR]
}
function addOption(selectbox,text,value ){
var optn = [COLOR="Blue"]opener[/COLOR].document.createElement("OPTION");
selectbox.options.add(optn); [COLOR="Green"]// insert then change values[/COLOR]
optn.text = text;
optn.value = value;
}
//opener.form1.contact.
</script>
<script type="text/javascript">
removeAllOptions(opener.[COLOR="Blue"]document[/COLOR].form1.customer_name)
addOption(opener.[COLOR="Blue"]document[/COLOR].form1.customer_name,"1","test1" )
addOption(opener.[COLOR="Blue"]document[/COLOR].form1.customer_name,"2","test2" )
addOption(opener.[COLOR="Blue"]document[/COLOR].form1.customer_name,"3","test3" )
addOption(opener.[COLOR="Blue"]document[/COLOR].form1.customer_name,"4","test4" )
</script>
[/CODE]

[I]language="javascript"[/I] language attributed is depreciated
Copy linkTweet thisAlerts:
@moiseszaragozaauthorOct 15.2010 — Thanks so much

I just updated my script and it works really good.

i was killing myself yesterday with that
×

Success!

Help @moiseszaragoza 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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