Jump to content

Recommended Posts

By combo boxes I mean the drop down box. And what I want is to have them greyed out (or read only) until the radio button is checked. I don't have any code on this so far as I want to add this to a page but have no clue how to start or what I need.

Ok. So I think I figured out how the code is supposed to be inserted and work but it's not working. Below is the code.

 

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PHGC Database<?php if (isset($title)) {echo "&#8212;{$title}";} ?></title>
<link href="phgcdatabase.css" rel="stylesheet" type="text/css" />

<script language="javascript">
  function enableSingle(formObj)
  {
    formObj.upn.disabled=false;
    formObj.farmnumber.disabled=false;
    formObj.trackernumber.disabled=false;
    formObj.username.disabled=false;
            
    formObj.experiment.disabled=true;
    formObj.treatment.disabled=true;
    formObj.assay.disabled=true;
    formObj.gene.disabled=true;
  }
  function enableGeneral(formObj)
  {
    formObj.upn.disabled=true;
    formObj.farmnumber.disabled=true;
    formObj.trackernumber.disabled=true;
    formObj.username.disabled=true;
            
    formObj.experiment.disabled=false;
    formObj.treatment.disabled=false;
    formObj.assay.disabled=false;
    formObj.gene.disabled=false;
  }
</script>
</head>

<body>
<div id="header">
    <img src="images/headerimage.jpg" />
</div>
<div id="wrapper">
    <?php include('includes/menu.inc.php'); ?>
    <?php include('includes/logoutbutton.inc.php'); ?>
    <div id="maincontent">
    	<h1>Search</h1>
        <h2>Please use the form below to search the database.</h2>
        <form id="search" method="post" action="search_results.php">
        <h2>Enter the information you wish to use to search.</h2>
        <fieldset id="interests">
        <p>
          <input name="searchType" type="radio" value="single" id="singlesearch" onClick="enableSingle(search)">
          <label for="singlesearch">Search based on information for a single pig.</label>
        </p>
        <p>
          <label for="upn">UPN:</label>
          <input name="upn" id="upn" type="text" class="formbox" disabled="true" />
        </p>
        <p>
          <label for="farmnumber">Farm Number:</label>
          <input name="farmnumber" id="farmnumber" type="text" class="formbox" disabled="true" />
        </p>
        <p>
          <label for="trackernumber">ItemTracker Number:</label>
          <input name="trackernumber" id="trackernumber" type="text" class="formbox" disabled="true" />
        </p>
        <p>
          <label for="username">UserName:</label>
          <input name="username" id="username" type="text" class="formbox" disabled="true" />
        </p>
        <p>
          <input name="searchType" type="radio" value="general" id="generalsearch" onClick="enableGeneral(search)">
          <label for="generalsearch">Search for multiple pigs based on general information.</label>
        </p>
          <p>
            <label for="experiment">Search using an experiment.</label>
            <select name="experiment" id="experiment" disabled="true">
              <option value="">Please select an experiment.</option>
              <?php
                for($j = 0; $j < count($experimentarray); $j++)
                {
                  $experimentid = $experimentarray[$j][0];
                  $experimentname = $experimentarray[$j][1];
                  echo '<option value="'.$experimentid.'">'.$experimentname.'</option>';  
                }
              ?>
            </select>
          </p>
          <p>
            <label for="treatment">Search using a treatment.</label>
            <select name="treatment" id="treatment" disabled="true">
              <option value="">Please select a treatment type.</option>
              <?php
                for($h = 0; $h < count($treatmentarray); $h++)
                {
                  $treatmentid = $treatmentarray[$h][0];
                  $treatmentname = $treatmentarray[$h][1];
                  echo '<option value="'.$treatmentid.'">'.$treatmentname.'</option>';  
                }  
              ?>
            </select>
          </p>
          <p>
            <label for="assay">Search using an assay.</label>
            <select name="assay" id="assay" disabled="true">
              <option value="">Please select an assay.</option>
              <?php
                for($h = 0; $h < count($assayarray); $h++)
                {
                  $assayid = $assayarray[$h][0];
                  $assayname = $assayarray[$h][1];
                  echo '<option value="'.$assayid.'">'.$assayname.'</option>';  
                }
              ?>
            </select>
          </p>
          <p>
            <label for="gene">Search using a gene.</label>
            <select name="gene" id="gene" disabled="true">
              <option value="">Please select a gene.</option>
              <?php
                for($g = 0; $g < count($genearray); $g++)
                {
                  $geneid = $genearray[$g][0];
                  $genename = $genearray[$g][1];
                  echo '<option value="'.$geneid.'">'.$genename.'</option>';
                }
              ?>
            </select>
          </p>
        </fieldset>

<script type="text/javascript" language="javascript">
function changeInfo(type){

document.getElementById(type + "Display").style.display = 'block';

}
</script>

 

That in the head

 

And for the body

 


<input type="radio" name="someName" onFocus="changeInfo('content');">

<div id="contentDisplay" style="display: none;">

Some content to show/hide...

</div>

 

That should work.

 

// edited a little...

Works for me when I just tested it...

 

Well it shows but obviously doesnt hide...

 

<html>
<head>
<title>Test</title>
<script type="text/javascript" language="javascript">
function changeInfo(type){

document.getElementById(type + "Display").style.display = 'block';
}
</script>
</head>
<body>
<input type="radio" name="someName" onFocus="changeInfo('content');">

<div id="contentDisplay" style="display: none;">

Some content to show/hide...

</div>
</body>
</html>

I copied that exactly into a new page and it still wouldn't work. The text isn't displayed when the radio button is clicked. Could it be some setting I have to ask the server manager to adjust? Thanks for all the help so far.

 

What browser/version are you using because Andy's example has worked on 3 separate browsers for me...

His page works on my browser as well. But when I copy the same thing over to a php script and upload it to the server and view it, it does not work.

 

http://www.animalgenome.org/lunney/TestPage.php

 

That is his same exact code but it won't display the text when you click the radio button.

http://www.animalgenome.org/lunney/TestPage.php

 

This worked for me as well, FF and IE 6...

 

Yes, it worked for me too (once I used FF) I was using google chrome and I guess it doesn't like that. *shrug*

 

Anyways, I got my original code working. Was a matter of referencing the form by name but not setting a name for it.

 

Thanks for all the help everyone.

Yes, it worked for me too (once I used FF) I was using google chrome and I guess it doesn't like that. *shrug*

 

Anyways, I got my original code working. Was a matter of referencing the form by name but not setting a name for it.

 

Thanks for all the help everyone.

 

If I were you I would test in FF first because it lives up to the W3 standards the best.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.