Hey guys,

I am trying to make a drop down menu that gives options such as (right, left, center) so that I can choose one of those and align the text in one of my layers. I am having trouble figuring out how to make this work so if someone can help me that would be great.

Basically I need a drop down menu with those three options, and when one of the options is chosen, I need it to call a javascript function onchange (i don't want to use a button, i just want to align the text instantly) and then I need the javascript function to use getElementById('mylayer') to change the alignment of the text in that layer. Can anyone help me? I'm sure it is simple and involves the values of my drop down menu, but I cannot manage to figure it out. Thanks!

Recommended Answers

All 2 Replies

Hey guys,

I am trying to make a drop down menu that gives options such as (right, left, center) so that I can choose one of those and align the text in one of my layers. I am having trouble figuring out how to make this work so if someone can help me that would be great.

Basically I need a drop down menu with those three options, and when one of the options is chosen, I need it to call a javascript function onchange (i don't want to use a button, i just want to align the text instantly) and then I need the javascript function to use getElementById('mylayer') to change the alignment of the text in that layer. Can anyone help me? I'm sure it is simple and involves the values of my drop down menu, but I cannot manage to figure it out. Thanks!

try this.........

<html>
<head>
<script type="text/javascript">

function alignl(ele){
     document.getElementById('lay').style.align=ele;
}
</script>
</head>
<body>
<layer id='lay'></layer>
<select id='s' name='s'  onchange="alignl(this.value);">
<option value="left">left</option>
<option value="right">right</option>
<option value="center">center</option>
<option value="top">top</option>
</select>
</body>
</html>

Thanks for the solution. I had already solved it myself, but since you posted the same exact solution that I came up with myself I will go ahead and add to your reputation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.