loganbest Posted September 6, 2007 Share Posted September 6, 2007 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 https://forums.phpfreaks.com/topic/68150-onchange-event-help/ Share on other sites More sharing options...
xenophobia Posted September 6, 2007 Share Posted September 6, 2007 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 https://forums.phpfreaks.com/topic/68150-onchange-event-help/#findComment-343000 Share on other sites More sharing options...
loganbest Posted September 12, 2007 Author Share Posted September 12, 2007 that works but I need to make the 'reason2' field change values. Link to comment https://forums.phpfreaks.com/topic/68150-onchange-event-help/#findComment-346607 Share on other sites More sharing options...
xenophobia Posted September 15, 2007 Share Posted September 15, 2007 Then you will have to give an id to your reason2 field <input type="text" name="reason2" id="reason2" value="MM/DD/YY" /> And modify the code alert into this: if(....){ document.getElementById("reason2").value = "When Real Photo is Uploaded"; } Link to comment https://forums.phpfreaks.com/topic/68150-onchange-event-help/#findComment-349013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.