Jump to content

[SOLVED] switch(document.getElementById(divID).style.display) error


HAVOCWIZARD

Recommended Posts

hi people need help, the search works perfect and display perfect , show the company names it found with underlineing, my problem is that when i click on it to display the info is gives me a javascript error on line 23 and it is the "switch(document.getElementById(divID).style.display)" ..if any body can help i will be very gratefull stuck with this the whole day, thanks.

 

<div>

<script language="JavaScript" type="text/JavaScript">

var useIE = false;

 

// Get browser type and set variable for type

if(navigator.userAgent.indexOf("MSIE")!=-1)

{

useIE = true;

}

else

{

useIE = false;

}

 

 

function showHideDIV(divID)

{

// our customary use ie settings

if(useIE)

{

switch(document.getElementById(divID).style.display)

{

case "none":

{

document.all[divID].style.display = "block";

break;

}

 

case "block":

{

document.all[divID].style.display = "none";

break;

}

}

}

// use something actually w3c complient :)

else

{

switch(document.getElementById(divID).style.display)

{

case "none":

{

document.getElementById(divID).style.display = "block";

break;

}

 

case "block":

{

document.getElementById(divID).style.display = "none";

break;

}

 

}

}

}

</script>

<h2>Search</h2>

<form name="search" method="post" action="<?=$PHP_SELF?>">

Seach for: <input type="text" name="find" />

 

 

</Select>

<input type="hidden" name="searching" value="yes" />

<input type="submit" name="search" value="Search" />

</form>

<?php

include "scripts/php/test1.php";

$searching = "yes";

$find = "bat staal";

?>

 

<?php

//This is only displayed if they have submitted the form

if ($searching =="yes")

{

echo "<h2>Results</h2><p>";

 

//If they did not enter a search term we give them an error

if ($find == "")

{

echo "<p>You forgot to enter a search term";

exit;

}

 

// We preform a bit of filtering

$find = strtoupper($find);

$find = strip_tags($find);

$find = trim ($find);

 

//Now we search for our search term, in the field the user specified

$data = mysql_query("SELECT * FROM registrations WHERE upper(register_companyName) LIKE'$find'"); 

 

$result_fnd = count($data);

//And we display the results

 

while ($result = mysql_fetch_array($data))

//echo $result['register_companyName'];

//echo " ";

//echo $result['register_telephoneNumber'];

//echo "<br>";

//echo $result['register_faxNumber'];

//echo "<br>";

//echo "<br>";

 

for($loop_fields = 0; $loop_fields <= 10; $loop_fields++)

{

// run through keywords list and create query

// sql query start

$result = mysql_fetch_array($data);

 

for ($loop_result = 0; $loop_result <= count($result_fnd); $loop_result++)

{

if($result != "")

{

 

 

echo '<div id="resultDIV' . $result . '" style="" class="textField">';

echo ' <table style="width:100%;">';

echo ' <tr>';

echo ' <td style="width:75%">';

// company name

echo ' <a href="javascript:showHideDIV(\'resultDropDownDIV' .$loop_results . '\')" class="linkResults">';

//ob_start("highlight");

echo htmlspecialchars( stripslashes( $result['register_companyName']) );

//ob_end_flush();

echo '</a>';

echo ' </td>';

echo ' </tr>';

 

echo ' <tr>';

echo ' <td>';

echo ' Relevancy: <img src="images/relevancy.gif" style="width:' . ($relevancy[$loop_results]["relevancy"]  / 2) . 'px; height:8px" alt="relevancy_rating" /> ' . $relevancy[$loop_results]["relevancy"] . '%';

echo ' <td>';

 

 

echo ' </tr>';

echo ' </table>';

 

echo ' <div id="resultDropDownDIV' . $result . '" style="width:95%; display:none;"> ';

echo ' <table style="width:100%;table-layout:fixed"> ';

 

if($result['register_companyName'])

{

// business

echo ' <tr> ';

echo ' <td style="width:20%; vertical-align:top"> ';

echo ' Business: ' ;

echo ' </td> ';

echo ' <td style="width:40%"> ';

echo ' ';

// start our highlight procedure

//ob_start("highlight");

echo htmlspecialchars( stripslashes( $result['register_companyName']  ) );

 

// end our highlight procedure

//ob_end_flush();

 

echo ' </td> ';

echo ' </td> ';

echo ' </tr> ';

}

if($return['register_description'])

{

// description

echo ' <tr> ';

echo ' <td style="vertical-align:top"> ';

echo ' Description: ';

echo ' </td> ';

echo ' <td> ';

echo ' <pre class="textField">';

ob_start("highlight");

echo htmlspecialchars( stripslashes( $return['register_description']  ) );

// end our highlight procedure

ob_end_flush();

echo "</pre>";

echo ' </td> ';

echo ' </tr> ';

}

echo ' <tr><td> </td></tr>';

echo ' </table> ';

 

echo ' </div> ';

echo '</div> ';

 

echo "<br />";

}

 

}

}

//This counts the number or results - and if there wasn't any it gives them a little message explaining that

$anymatches=mysql_num_rows($data);

if ($anymatches == 0)

{

echo "Sorry, but we can not find an entry to match your query<br><br>";

}

 

//And we remind them what they searched for

echo "<b>Searched For:</b> " .$find;

}

?>

 

Link to comment
Share on other sites

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.