This topic is locked

Conditional Access to Field - newbie

2/20/2009 1:11:06 PM
ASPRunnerPro General questions
K
kwarden@mpr.com author

Greetings - need help please to only allow editing/entry to a field in database if a previous field contains data. I'm sure this is easy, so please don't laugh to loud!
I found a script on the forum that displays, but blanks out, the "State" field if the "Country" field is not "US". This is what I want, but I'm clueless as how to adapt it to my need or even where it goes.
Field names - the first field listed needs to be completed before the next two field is allowed to be edited.

RUN Lead Accept

RUN Services Lead
Here's the code I found:

[codebox]<script>

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

{

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

document.forms.editform.value_state.disabled=false;

else

{

document.forms.editform.value_state.disabled=true;

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

}

}

</script>[/codebox]

A
agruspe 2/24/2009

Check out this topic. http://www.asprunner.com/forums/index.php?showtopic=10884
This is an example using a check box wherein it must be checked first before a user can enter data into the 2 other fields.

K
kwarden@mpr.com author 2/25/2009

Thank you very much Arnel. Can you help me with how I would enter my two-word field names into the code?
I'm sorry I just do not know enough about asp to understand how to enter my field names...would I enter .valueLead Accept., or .value"Lead Accept"., or do I need to change my field names to one-word, or... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=38245&image=1&table=forumreplies' class='bbc_emoticon' alt=':huh:' /> I know this must be simple, though everything I try just makes everything angry.
My simplified field name examples:
Lead Accept

Services Response
Thank you!

K
kwarden@mpr.com author 3/2/2009

Hello again! Figured out how to find the HTML Field names. Can not get to work.
Can this be done with an event? That'd be much easier....
Here's the script and I've tried placing it before and after the <body> as well as within the <body>
[codebox]

<script>

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

{

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

document.forms.editform.value_Other_Fieldname.disabled=false;

else

{

document.forms.editform.value_Other_Fieldname.disabled=true;

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

}

}

</script>

[/codebox]

Sergey Kornilov admin 3/2/2009

Events happen on server side while you need to implement your logic on client side in Javascript.
You can post your application to Demo Account and send us URL for investigation.