Solved

Need to change radio buttons into drop down.

Posted on 2002-03-14
10
137 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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 18

Expert Comment

by:bruno
Comment Utility
<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
Comment Utility
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
Comment Utility
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
 
LVL 30

Expert Comment

by:third
Comment Utility
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
Comment Utility
forkush,

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


BRUNO
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This comment, combined with Third's follow-up comment, does the trick.
0
 
LVL 18

Expert Comment

by:bruno
Comment Utility
>>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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now