Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

radio button selection to unhide div info

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
0
0
CA
Hi, i seem to be having difficulties with the following and was wondering if some smart eyes can help me with it. Thanks

<script type="text/javascript"><!--
function getObjRef(id) {
if(document.getElementById) { return document.getElementById(id); }
if(document.all) { return document.all[id]; }
}

function display1(selected) { //selected is the radio input option

var el = getObjRef('rad1'); //gets the object reference for the element

if(val == '1aa1') { //if val is set to '1aa1' show the textbox

el.style.display='block';

} else if (val == '1aa2') {

el.style.display='block';

else { //else hide it or keep it hidden.

el.style.display='none';
}
}
// -->
</script>

//////html//////////

<input type="radio" id="rad1" name="r1" value="1aa1" onClick="javascript:display1();">Canada&nbsp;
<input type="radio" id="rad1" name="r1" value="1aa2" onClick="javascript:display1();">USA


///////other info/////
form name="frmRecruitmentList
 
made adjustments but not sure why you would want this

Code:
<script type="text/javascript"><!--
function getObjRef(id) {
  if(document.getElementById) { return document.getElementById(id); }
  if(document.all) { return document.all[id]; }
}

function display1() { //selected is the radio input option

  var el = getObjRef('rad1'); //gets the object reference for the element
  var val = el.value;

  if(val == '1aa1') { //if val is set to '1aa1' show the textbox

    el.style.display='block';

  } else if (val == '1aa2') {

    el.style.display='block';

 } else {  //else hide it or keep it hidden.

    el.style.display='none';
  }
}
// -->
</script>
 
I think this is your problem:
Code:
<script type="text/javascript"><!--
function getObjRef(id) {
  if(document.getElementById) { return document.getElementById(id); }
  if(document.all) { return document.all[id]; }
}

function display1(selected) { //selected is the radio input option

  var el = getObjRef('rad1'); //gets the object reference for the element
  [i][gray]//val is not being defined[/gray][/i]
  [!]var val = String(el.value);[/!]
  if(val == '1aa1') { //if val is set to '1aa1' show the textbox

    el.style.display='block';

  } else if (val == '1aa2') {

    el.style.display='block';

  else {  //else hide it or keep it hidden.

    el.style.display='none';
  }
}
// -->
</script>

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
good eye steve

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top