Client Script - Hide Variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 10:47 AM
I have no idea why this script isn't working, it seems to be working in every other client script I have going.
This is my client script that on submit, if the number in quantity is quoted, clear the vendor as well as hide the rest of the variables on the submitted request or if not, clear the first quantity quoted. when I submit the request with u_quantity_quoted_2 blank, the vendor clears out but the rest of the variable are visible. what am I missing? does it matter that this was a custom table?
function onSubmit() {
//Type appropriate comment here, and begin script below
var quote = parseInt(g_form.getValue('u_quantity_quoted_2'));
// if quote < 0, hide quantity left, model, price, and quantity order
if(quote < 0){
g_form.clearValue('u_vendor');
g_form.setDisplay('u_quantity_left_2',false);
g_form.setDisplay('u_model_2',false);
g_form.setDisplay('u_price_2',false);
g_form.setDisplay('u_quantity_order_2',false);
} else {
g_form.clearValue('u_quantity_quoted');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2015 07:54 AM
right, but I would like more 'if' statements and I don't know if that's why its not working properly. it will eventually look something like this
function onLoad(){
if(g_form.isNewRecord()){
if (quantity_quote == ''){
g_form.setVisible(quantity_quote, false);
g_form.setVisible(quantity_left,false);
g_form.setVisible(model, false);
g_form.setVisible(price, false);
g_form.setVisible(quantity_order, false);
}
}
if (quantity_quote2 == ''){
g_form.setVisible(quantity_quote2, false);
g_form.setVisible(quantity_left2, false);
g_form.setVisible(model2, false);
g_form.setVisible(price2, false);
g_form.setVisible(quantity_order2, false);
}
}
if (quantity_quote3 == ''){
g_form.setVisible(quantity_quote3, false);
g_form.setVisible(quantity_left3, false);
g_form.setVisible(model3, false);
g_form.setVisible(price3, false);
g_form.setVisible(quantity_order3, false);
}
}
if (quantity_quote4 == ''){
g_form.setVisible(quantity_quote4, false);
g_form.setVisible(quantity_left4, false);
g_form.setVisible(model4, false);
g_form.setVisible(price4, false);
g_form.setVisible(quantity_order4, false);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 12:29 PM
Hi Alex,
If you're using an onSubmit script, then displaying/hiding the variables would not have any effect on your form the next time it loads. Perhaps you may want to try using an onLoad catalog client script.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 12:32 PM
If I did onLoad, wouldn't that mean that the u_quantity_quote_2 would have to automatically fill itself out, otherwise when someone goes to fill in the request, all the variables will be hidden already? at least that's how I understand it...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 12:38 PM
It depends on how the value is getting populated . If it's blank at the beginning then you can you an OnChange client script instead.
Thanks,
Berny