mick-pl
09-06-2006, 07:44 AM
Hi,
I'm not too good at javascript and I got a problem.
I've installed a modification for IB forum which let users to choose topic prefix befor posting.
How should I modyfie the script to get an error in a box when user don't choose any option from dropdown menu?
Here is a bit of code with the options:
</tr><tr>
<td class="pformleft">Prefiks Tematu</td>
<td class="pformright"><select name='TopicPrefix' class='forminput'><option value=''>Bez Prefiksu</option><option value=''>-----------</option><option value='Szukam: '>Szukam: </option><option value='Wynajmę: '>Wynajmę: </option></select> <i><small>Pojawi się automatycznie przed tematem</small></i></td>
</tr>
And here is fragment of javascript:
<script type="text/javascript">
<!--
var MessageMax = "{ipb.lang['the_max_length']}";
var Override = "{ipb.lang['override']}";
var dontpassgo = 0;
MessageMax = parseInt(MessageMax);
if ( MessageMax < 0 ){
MessageMax = 0;
}
function emo_pop(){
window.open("index.{ipb.vars['php_ext']}?act=legends&CODE=emoticons&s={ipb.session_id}","Legends","width=250,height=500,resizable=yes,scrollbars=yes");
}
function bbc_pop(){
window.open("index.{ipb.vars['php_ext']}?act=legends&CODE=bbcode&s={ipb.session_id}","Legends","width=700,height=500,resizable=yes,scrollbars=yes");
}
function attach_pop(url){
window.open("{$ibforums->js_base_url}act=Post&CODE=20&"+url,"Attachments","width=500,height=400,resizable=yes,scrollbars=yes");
}
function CheckLength(){
MessageLength = document.REPLIER.Post.value.length;
message = "";
if (MessageMax > 0){
message = "{ipb.lang['js_post']}: {ipb.lang['js_max_length']} " + MessageMax + " {ipb.lang['js_characters']}.";
}
else{
message = "";
}
alert(message + " {ipb.lang['js_used']} " + MessageLength + " {ipb.lang['js_characters']}.");
}
function ValidateForm(isMsg){
MessageLength = document.REPLIER.Post.value.length;
errors = "";
// Check for remove attachments
if ( document.REPLIER.removeattachid.value > 0 ){
okdelete = confirm("{ipb.lang['remove_attach']}");
if ( okdelete == true ){
return true;
}
else{
document.REPLIER.removeattachid.value = 0;
return false;
}
}
if (isMsg == 1){
if (document.REPLIER.msg_title.value.length < 2){
errors = "{ipb.lang['msg_no_title']}";
}
}
if (MessageLength < 2){
errors = "{ipb.lang['js_no_message']}";
}
if (MessageMax !=0){
if (MessageLength > MessageMax){
errors = "{ipb.lang['js_max_length']} " + MessageMax + " {ipb.lang['js_characters']}. {ipb.lang['js_current']}: " + MessageLength;
}
}
if (errors != "" && Override == ""){
alert(errors);
return false;
}
else{
document.REPLIER.submit.disabled = true;
return true;
}
}
function removeattach(id){
if ( id != "" ){
var Override = 1;
document.REPLIER.removeattachid.value = id;
}
}
// IBC Code stuff
var text_enter_url = "{ipb.lang['jscode_text_enter_url']}";
var text_enter_url_name = "{ipb.lang['jscode_text_enter_url_name']}";
var text_enter_image = "{ipb.lang['jscode_text_enter_image']}";
var text_enter_email = "{ipb.lang['jscode_text_enter_email']}";
var text_enter_flash = "{ipb.lang['jscode_text_enter_flash']}";
var text_code = "{ipb.lang['jscode_text_code']}";
var text_quote = "{ipb.lang['jscode_text_quote']}";
var error_no_url = "{ipb.lang['jscode_error_no_url']}";
var error_no_title = "{ipb.lang['jscode_error_no_title']}";
var error_no_email = "{ipb.lang['jscode_error_no_email']}";
var error_no_width = "{ipb.lang['jscode_error_no_width']}";
var error_no_height = "{ipb.lang['jscode_error_no_height']}";
var prompt_start = "{ipb.lang['js_text_to_format']}";
var help_bold = "{ipb.lang['hb_bold']}";
var help_italic = "{ipb.lang['hb_italic']}";
var help_under = "{ipb.lang['hb_under']}";
var help_font = "{ipb.lang['hb_font']}";
var help_size = "{ipb.lang['hb_size']}";
var help_color = "{ipb.lang['hb_color']}";
var help_close = "{ipb.lang['hb_close']}";
var help_url = "{ipb.lang['hb_url']}";
var help_img = "{ipb.lang['hb_img']}";
var help_email = "{ipb.lang['hb_email']}";
var help_quote = "{ipb.lang['hb_quote']}";
var help_list = "{ipb.lang['hb_list']}";
var help_code = "{ipb.lang['hb_code']}";
var help_click_close = "{ipb.lang['hb_click_close']}";
var list_prompt = "{ipb.lang['js_tag_list']}";
-->
</script>
I added:
if (document.REPLIER.TopicPrefix.select = ''){
errors = "Podaj prefiksa";
}
...but it doesn't work. :(
I'm not too good at javascript and I got a problem.
I've installed a modification for IB forum which let users to choose topic prefix befor posting.
How should I modyfie the script to get an error in a box when user don't choose any option from dropdown menu?
Here is a bit of code with the options:
</tr><tr>
<td class="pformleft">Prefiks Tematu</td>
<td class="pformright"><select name='TopicPrefix' class='forminput'><option value=''>Bez Prefiksu</option><option value=''>-----------</option><option value='Szukam: '>Szukam: </option><option value='Wynajmę: '>Wynajmę: </option></select> <i><small>Pojawi się automatycznie przed tematem</small></i></td>
</tr>
And here is fragment of javascript:
<script type="text/javascript">
<!--
var MessageMax = "{ipb.lang['the_max_length']}";
var Override = "{ipb.lang['override']}";
var dontpassgo = 0;
MessageMax = parseInt(MessageMax);
if ( MessageMax < 0 ){
MessageMax = 0;
}
function emo_pop(){
window.open("index.{ipb.vars['php_ext']}?act=legends&CODE=emoticons&s={ipb.session_id}","Legends","width=250,height=500,resizable=yes,scrollbars=yes");
}
function bbc_pop(){
window.open("index.{ipb.vars['php_ext']}?act=legends&CODE=bbcode&s={ipb.session_id}","Legends","width=700,height=500,resizable=yes,scrollbars=yes");
}
function attach_pop(url){
window.open("{$ibforums->js_base_url}act=Post&CODE=20&"+url,"Attachments","width=500,height=400,resizable=yes,scrollbars=yes");
}
function CheckLength(){
MessageLength = document.REPLIER.Post.value.length;
message = "";
if (MessageMax > 0){
message = "{ipb.lang['js_post']}: {ipb.lang['js_max_length']} " + MessageMax + " {ipb.lang['js_characters']}.";
}
else{
message = "";
}
alert(message + " {ipb.lang['js_used']} " + MessageLength + " {ipb.lang['js_characters']}.");
}
function ValidateForm(isMsg){
MessageLength = document.REPLIER.Post.value.length;
errors = "";
// Check for remove attachments
if ( document.REPLIER.removeattachid.value > 0 ){
okdelete = confirm("{ipb.lang['remove_attach']}");
if ( okdelete == true ){
return true;
}
else{
document.REPLIER.removeattachid.value = 0;
return false;
}
}
if (isMsg == 1){
if (document.REPLIER.msg_title.value.length < 2){
errors = "{ipb.lang['msg_no_title']}";
}
}
if (MessageLength < 2){
errors = "{ipb.lang['js_no_message']}";
}
if (MessageMax !=0){
if (MessageLength > MessageMax){
errors = "{ipb.lang['js_max_length']} " + MessageMax + " {ipb.lang['js_characters']}. {ipb.lang['js_current']}: " + MessageLength;
}
}
if (errors != "" && Override == ""){
alert(errors);
return false;
}
else{
document.REPLIER.submit.disabled = true;
return true;
}
}
function removeattach(id){
if ( id != "" ){
var Override = 1;
document.REPLIER.removeattachid.value = id;
}
}
// IBC Code stuff
var text_enter_url = "{ipb.lang['jscode_text_enter_url']}";
var text_enter_url_name = "{ipb.lang['jscode_text_enter_url_name']}";
var text_enter_image = "{ipb.lang['jscode_text_enter_image']}";
var text_enter_email = "{ipb.lang['jscode_text_enter_email']}";
var text_enter_flash = "{ipb.lang['jscode_text_enter_flash']}";
var text_code = "{ipb.lang['jscode_text_code']}";
var text_quote = "{ipb.lang['jscode_text_quote']}";
var error_no_url = "{ipb.lang['jscode_error_no_url']}";
var error_no_title = "{ipb.lang['jscode_error_no_title']}";
var error_no_email = "{ipb.lang['jscode_error_no_email']}";
var error_no_width = "{ipb.lang['jscode_error_no_width']}";
var error_no_height = "{ipb.lang['jscode_error_no_height']}";
var prompt_start = "{ipb.lang['js_text_to_format']}";
var help_bold = "{ipb.lang['hb_bold']}";
var help_italic = "{ipb.lang['hb_italic']}";
var help_under = "{ipb.lang['hb_under']}";
var help_font = "{ipb.lang['hb_font']}";
var help_size = "{ipb.lang['hb_size']}";
var help_color = "{ipb.lang['hb_color']}";
var help_close = "{ipb.lang['hb_close']}";
var help_url = "{ipb.lang['hb_url']}";
var help_img = "{ipb.lang['hb_img']}";
var help_email = "{ipb.lang['hb_email']}";
var help_quote = "{ipb.lang['hb_quote']}";
var help_list = "{ipb.lang['hb_list']}";
var help_code = "{ipb.lang['hb_code']}";
var help_click_close = "{ipb.lang['hb_click_close']}";
var list_prompt = "{ipb.lang['js_tag_list']}";
-->
</script>
I added:
if (document.REPLIER.TopicPrefix.select = ''){
errors = "Podaj prefiksa";
}
...but it doesn't work. :(