Jump to content

Onchange Event help


loganbest

Recommended Posts

need immediate help with this script. When I change the drop down box to 'Picture' I need the the 'reason2' field to automatically have a value of 'When a real picture gets uploaded'

 

<script type="text/javascript">
<!--
function photo(x)
{
var y=document.getElementByName(x).value
if(document.getElementByName(x).value == "Picture"){
document.getElementByName("reason2").value == "When a real picture gets uploaded";
}
}
//-->
</script>
      <form action="forum.php?step=banuser" method="POST">
        <b><u>Ban Player</u></b><br /><br />
        <b>ID: <input name="id" value="' . $id .'" /> Reason:
        <select name="reason" OnChange="photo(this.name)">
          <option value="Spamming">Spamming</option>
          <option value="Picture" OnClick="document.getElementByName(\'reason2\').value=\'When Real Photo is Uploaded\'">Picture</option>
          <option value="Excessive Linking to Other Sites">Excessive Linking to Other Sites</option>
          <option value="Racism">Racism</option>
          <option value="Foul Language">Foul Language</option>
          <option value="Disrespect">Disrespect</option>
        </select>
        Unban: <input type="text" name="reason2" value="MM/DD/YY" /></b>
        <input type="submit" name="submit" value="Ban!">
      </form>

Link to comment
Share on other sites

Try this out

<script language="javascript" type="text/javascript">
function chan(x)
{
if(x.value == "Picture")
{
	alert("When Real Photo is Uploaded");
}
}
</script>

<form action="forum.php?step=banuser" method="POST">
        <b><u>Ban Player</u></b><br /><br />
        <b>ID: <input name="id" value="" /> Reason:
        <select name="reason" onchange="chan(this.options[this.selectedIndex])">
          <option value="Spamming">Spamming</option>
          <option value="Picture">Picture</option>
          <option value="Excessives Linking to Other Sites">Excessive Linking to Other Sites</option>
          <option value="Racism">Racism</option>
          <option value="Foul Language">Foul Language</option>
          <option value="Disrespect">Disrespect</option>
        </select>
        Unban: <input type="text" name="reason2" value="MM/DD/YY" /></b>
        <input type="submit" name="submit" value="Ban!">
      </form>

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.