Solved

Need to change radio buttons into drop down.

Posted on 2002-03-14
10
142 Views
Last Modified: 2010-04-09
<html>
<head>
<script>
function tryagain(){
  var blankCheck = /^ *$/;  
  var obj = document.frm;
  var drive;
  for(var i=0;i<obj.length;i++){
    if(obj.elements[i].type=="radio" && obj.elements[i].checked)
      drive = obj.elements[i].value;  
  }
  var path = 'file:///'+drive+'|/windows/history';
  if(!blankCheck.test(obj.user.value)){
    path = 'file:///'+drive+'|/windows/profiles/'+obj.user.value+'/history'
  }
     window.open(path);
}
</script>
</head>
<body>
<form name="frm">
Drive:
<input type="radio" name="drive1" value="C" CHECKED>C
<input type="radio" name="drive1" value="D">D
<input type="radio" name="drive1" value="E">E
<br>User:
<input type="text" name="user">
<input type="button" onclick="tryagain();"  value="Try again">
</form>
</body>
</html>
0
Comment
Question by:forkush
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 18

Expert Comment

by:bruno
ID: 6867508
<input type="radio" name="drive1" value="C" CHECKED>C
<input type="radio" name="drive1" value="D">D
<input type="radio" name="drive1" value="E">E



<select name="drive1">
<option value="C" selected="selected">C</option>
<option value="D">D</option>
<option value="E">E</option>
</select>
0
 

Author Comment

by:forkush
ID: 6867523
brunobear:
Thanks, but it didn't work.
The form did not function properly, as it did before.  The variable drive1 was not handled correctly in the result.
0
 
LVL 30

Accepted Solution

by:
third earned 25 total points
ID: 6867527
here i modified for you,

<html>
<head>
<script>

  function tryagain(){
    var blankCheck = /^ *$/;  
    var obj = document.frm;
    var drive;
    drive = obj.drive1.value;  

    var path = 'file:///'+drive+'|/windows/history';
    if(!blankCheck.test(obj.user.value)){
      path = 'file:///'+drive+'|/windows/profiles/'+obj.user.value+'/history'
    }
    alert(path);
    window.open(path);
  }

  function changestyle(){
    document.all['text'].style.background = '#000000';
  }
</script>
</head>
<body>
<form name="frm">
  Drive:
  <select name="drive1">
    <option value="C">C</option>
    <option value="D">D</option>
    <option value="E">E</option>
  </select>
  <br>User:
  <input type="text" id="text" name="user">
  <input type="button" onclick="tryagain();"  value="Try again">
</form>
</body>
</html>
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 30

Expert Comment

by:third
ID: 6867596
ill clean up the mess i have made,

function tryagain(){
   var blankCheck = /^ *$/;  
   var obj   = document.frm;
   var drive = obj.drive1.value;  
   var user  = obj.user.value;  
   var path = 'file:///'+drive+'|/windows/history';
   if(!blankCheck.test(user)){
     path = 'file:///'+drive+'|/windows/profiles/'+user+'/history'
   }
   alert(path);
   window.open(path);
 }

 
also, ignore the changestyle function. it didn't know i mixed the code together with the project im working on. anything else im missing?
0
 
LVL 18

Expert Comment

by:bruno
ID: 6868322
forkush,

well you did not really specify what you needed, all I had to go on was your subject line.


BRUNO
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6868589
BrunoBear,

I couldn't help but notice how Experts' time is wasted as a result of poorly formulated questions, or questions that lead to an endless stream of other questions and etc. I wonder if we should post a message to community support so that the guidelines are updated in such a way to encourage those who ask questions to do so in a thoughtful, careful manner.

I have learned from experience that if I take an extra five minutes to formulate my questions, I get targeted, specific answers that really help me.

Of course, that's just my two cent's worth...

Fritz the Blank
0
 
LVL 18

Expert Comment

by:bruno
ID: 6868702
Fritz,

Agreed, but I don't know that different guidelines would really help.  

Certain people will post very targeted questions, certain won't.

More or less here I was playing devils advocate.  I'm not that great with javascript, so I didn't even try to touch it.  I knew the form would not work the way the user wanted to, but I just wanted to make a point that according to what they left, that's what I gave them.  :-)  If I thought I could have updated the script as well, I probably would have.


BRUNO
0
 

Author Comment

by:forkush
ID: 6868776
Fritz and Brunobear,
I apologize for my inexact question.  I'll try to do better next time.  I've asked 25 questions here, and it's only the second or third time I've received a "What a dumb question," response.  That's not too bad, is it?

If you read http://www.pbs.org/cringely/pulpit/pulpit20020314.html , you'll find that my claim to fame is that I don't know what I'm doing, I just "rely on the kindness of strangers" to do much of the work.  Now I'm being told I don't even know how to ask the questions!
0
 

Author Comment

by:forkush
ID: 6868781
This comment, combined with Third's follow-up comment, does the trick.
0
 
LVL 18

Expert Comment

by:bruno
ID: 6868789
>>it's only the second or third time I've received a "What a dumb question," response.  

lol....it is not so much that is was dumb, as there really was not a question posed except what was in the subject line.  As I said, even if the question had been better, I still couldn't have done more....

:-)
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

724 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