?
Solved

Alert Box - DropDown List

Posted on 2003-03-04
18
Medium Priority
?
461 Views
Last Modified: 2008-03-10
I'm trying to create a dropdown list within an alert box using JavaScript.  How does that code look?  Thanks for any help you can provide.
0
Comment
Question by:luckydog374
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 2
  • +3
18 Comments
 
LVL 4

Expert Comment

by:jonnal
ID: 8067712
hi try this

<input TYPE="TEXT" NAME="TT" ID="KK"><br><br><br><br><br>
<select NAME="TEMP" onChange="alert(this.options[this.selectedIndex].value)">
<option value></option>
<option value="AAAAAA">AAAAAA</option>
<option value="BBBBBB">BBBBBB</option>
<option value="CCCCCC">CCCCCC</option>
<option value="DDDDDD">DDDDDD</option>
<option value="EEEEEE">EEEEEE</option>
</select>
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8067724
I believe it is impossible to do this in an alert, however you can have a pop-up window that looks like an alert and use that.
0
 
LVL 7

Expert Comment

by:cubrovic
ID: 8067725
What are you want?
To have a dropdown list in alert message box ?
If so that's impossible.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:lil_puffball
ID: 8067794
for example...

window.open("alert.htm","newwin","height=100,width=300",toolbar="no",menubar="no",scrollbars="no",resizable="no",location="no",directories="no",statud="no");

And in alert.htm, make the background gray, write anything you want and add a button like this...

<input type="button" onClick="self.close()">OK</a>

which will make it just like an alert.
0
 

Author Comment

by:luckydog374
ID: 8067810
jonnal,

I'm trying to have the dropdown list within the alert box.
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8067815
oh, in your window.open you should also add something like left="150",top="150" so it centers.
0
 
LVL 4

Expert Comment

by:jonnal
ID: 8067970
well then go with lil_puffballs code
0
 
LVL 4

Accepted Solution

by:
jonnal earned 160 total points
ID: 8068101
hi again try this in IE (6 probably)

<HEAD>
<TITLE>Creating a Link and Retrieve the URL</TITLE>
<LINK REL="stylesheet" HREF="samples.css" TYPE="text/css"/>
</HEAD>
<BODY>
<H1 unselectable="on">Creating a Link and Retrieve the URL</H1>
<script>
function AddLink()
{//identify selected text
var sText = document.selection.createRange();
if (sText.text!=""){
  //create link
  document.execCommand("CreateLink");
  //replace text with URL
  if (sText.parentElement().tagName == "A"){
    sText.parentElement().innerText=sText.parentElement().href;
    document.execCommand("ForeColor","false","#FF0033");
  }
}
else{
    alert("Please select some blue text!");
}
}
</script>

<P unselectable="on">Select any portion of the following blue text, such as "My favorite Web site". Click the button to turn the selected text into a link.  The text will be changed to the URL that you specify.</P><P style="color=#3366CC">My favorite Web site is worth clicking on. Don't forget to check out my favorite music group!</P>
<BUTTON onclick="AddLink()" unselectable="on">Click to add link</BUTTON>
<P class="viewsource" unselectable="on">To view the source code, right-click this page and choose View Source from the shortcut menu.</P>

</A>
</BODY>
</HTML>
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8068172
uh, jonnal? I'm not sure but I think you posted in the wrong place...
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8068290
oh, ok never mind, I see...when you click on the button there's a drop-down on the pop-up..I was just wondering what the other stuff was doing there.

Well, that's very cool, I didn't know you could do that with pop-ups...:)
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8068334
Why dropdown in an 'alert-type' box?? What do you want when something is selected from the dropdown? And so on. What are you trying to implement?
0
 

Author Comment

by:luckydog374
ID: 8072844
lil puffball,

I agree - that's a cool usage of alert boxes, however it's not exactly what I need.

Currently I have an alert box with a field that the user types in text.  Instead, I'd prefer to limit the data by having dropdown list with limited options that I specify.

If this isn't possible with JavaScript, would it work with VBScript?  
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8075562
jonnal,
How exactly does that work? I have narrowed it down to see that

document.execCommand("CreateLink");

is really what is doing the alert box. What exactly is execCommand? (I am not very good at javascript so please forgive me if this is a really stupid question! :) )

0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8075576
oh, also I was wondering what effect "unselectable=on" has?
0
 
LVL 4

Expert Comment

by:jonnal
ID: 8076295
hi lil

dont really know
you seem to get alot from not to much code
its a ms dhtml thing !!

here is a microsoft artical on it

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/commandids.asp
0
 
LVL 12

Assisted Solution

by:lil_puffball
lil_puffball earned 160 total points
ID: 8323596
luckydog it's been a long time, just showing you an example. This is very simple but you can jazz it up to look more like an alert.

<script>
var str="<center><body bgcolor=eaeadd><form>Please Select: <select>";
str+="<option>Opt1<option>Opt2<option>Opt3<option>Opt4</select>";
str+="<p><input type=button style='font-size:12px' value='     OK     ' onClick='self.close();'></form></body>";
var win=false;
function openwin(){
win=window.open("","","height=70,width=200,left=200,top=200");
win.document.write(str);
alert('s')
}
</script>

<body onFocus="if(win&&!win.closed){win.focus();}">
<a href="#" onClick="openwin()">asd</a>
<input type=text onKeyUp="document.bgColor=this.value">
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10097595
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: jonnal {http:#8068101} & lil_puffball {http:#8323596}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question