This topic is locked

Clear datepicker fields when dropdwon changes

8/7/2008 8:08:37 AM
ASPRunnerPro General questions
Z
zion4ever author

Hi all,
Does anyone know how to clear the date selection fields onchange of a dropdownmenu?

I have a dropdown meny with choices:

  • Rented
  • Available
  • Reserved
    Now when someone comes back with the rented stuff the dropdown will change from rented to available. However I would like the two fields (named DATE RENTED and DATE BACK) to jump onto blank (nothing selected). Otherwise the person who uses the system will have to clear it out manually.
    Anybody..any ideas...plz???
    Hans

J
Jane 8/7/2008

Hi,
add custom javascript code to the edit page on the Visual Editor tab in HTML mode.

Here is just a sample:

{literal}

<script>

document.forms.editform.value_FieldName.onchange=function()

{

if(this.options[this.selectedIndex].value=='Available')

{

document.forms.editform.monthvalue_DATE_RENTED.value='';

document.forms.editform.dayvalue_DATE_RENTED.value='';

document.forms.editform.yearvalue_DATE_RENTED.value='';

}

}

</script>

{/literal}

Z
zion4ever author 8/7/2008

Thnx Jane. But where do I put it. (before record, after record, before display?)

Z
zion4ever author 8/7/2008

Never mind. I've misread your post
Thnx

Z
zion4ever author 8/26/2008

Hello,
Just one quick question in addition to my earlier question:
How do I get to know the names of the form elements?

I've used the code you sent me. It works great. However, I have a richttextbox which displays the field NOTES
document.forms.editform.value_Notes.value=''; doesn't seem to work.
TIA
Hans

J
Jane 8/26/2008

Hi,
here are some tips:

  • open page in browser,
  • right click on the page,
  • select View Source or View Page Source
  • and check HTML code:
    <input type="text" name="value_FieldName" value="...">



Please note field names are case sensitive here.

Z
zion4ever author 8/26/2008

Thank you

Z
zion4ever author 8/27/2008

Hi there,
Sorry to bother you again. But when i use the javascript ocde, the fileds clear out perfectly. However, when saving them, they reapper and get saved in the mysql db. Plz help me out

J
Jane 8/28/2008

Hi,
you need to clear it in the Before record added/updated event on the Eventstab.

Here is a sample:

if dict("FieldName")="Available" then

dict("DATE RENTED") = ""

end if