Jump to content

[SOLVED] textarea not disabling? no responding text....


MikeDXUNL

Recommended Posts

alright. this forum is to create a Category or Forum. The user selects Category or Forum from a drop-down list and then if it is equal to 'Category' the Forum Description textarea will disable... if it is equal to 'Forum'. then it is enabled.

 

 

if there is an easier way of pulling this off, i would be thankful but here is the coding. :P

 

 

 

 

 

 

createforum.php

	<form action="createforum.php" method="post">
	<table width="50%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="25%" valign="top"><strong>Forum Type:</strong></td>
<td width="75%">
<select name="forumtype" onchange="forumtype(this.value)">
<option value="no">----------------------</option>
<option value="Category">Category</option>
<option value="Forum">Forum</option>
</select>
<div id="txtHint"> </div>
</td>
</tr>


<tr>
<td valign="top"><strong>Forum Description:</strong></td>
<td valign="top">
<textarea id="forumdesc" name="forumdesc" cols="30" rows="10"></textarea>
</td>
</tr>

</table>
<input type="submit" value="Submit" />
	</form>

 

 

 

 

js/forumtype.js

var xmlHttp

function forumtype(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ajax/forumtype.php";
url=url+"?ftype="+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;

if (xmlHttp.responseText == ' ')
        document.getElementById("forumdesc").disabled = true;
    else
         document.getElementById("forumdesc").disabled = false;   
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

 

 

 

 

ajax/forumtype.php

<?php


if ($_GET['ftype'] == "Category") {
echo "";
} elseif($_GET['ftype'] == "Forum") {
echo "hello world";
}



?>

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.