This topic is locked
[SOLVED]

  Default Value (field that pulls value from another table

10/18/2010 4:48:30 PM
ASPRunnerPro General questions
J
Jay123 author

Hi!
I am using ASP Runner 6.1.
Is it possible for the default value to get displayed to a field that pulls value from another table (through lookup)?
I have field2 on Add page of Table A which pulls data from Table B when a certain item is selected on field1.
I can assign a default value but it doesn't get displayed.
Thanks,

Jay

Sergey Kornilov admin 10/19/2010

It's possible.

  1. Use BeforeProcessAdd event to run SQL Query and retrieve value value from another table. Use DAL for this purpose.

    Save this value to session variable.
  2. Set this session variable as a default value for the field.

J
Jay123 author 10/19/2010

Hi Sergey,
Will this work if the users and PCs are different for Tables A & B? If I remember it right, session variable is ideal if the same person will enter the value on those tables in the same PC.
If the above will not work, do you have any suggestions?
I was thinking of using the Add Page Before Display event but once I have assigned a value using "xt.assign", the value doesn't change anymore when an item is selected on field1.
Thanks,

Jay

Sergey Kornilov admin 10/19/2010

Jay,
you are overthinking it. Session variables are the way to go here.

J
Jay123 author 10/19/2010

Hi Sergey,
I guess I'm doing it wrong and I didn't explain it well.
Suppose I want my default value of field2 on Table A as "Nice". I just want "Nice" to be displayed on field2 of Table A if there's no record on Table B. If there's record on Table B, I want "Nice" to be replaced by value from Table B based from the item that will be selected on field1.
Here's a sample:

if Table B has no record, field2 (of Table A) = "Nice"

if Table B has record,

field2 (of Table A) = "Hi" [if field1 (of Table A) = 1]

field2 (of Table A) = "Hello" [if field1 (of Table A) = 2]

Note: I set field2 as Edit box with AJAX popup (lookup table) and dependent on the value of field1.
Thanks,

Jay

Sergey Kornilov admin 10/20/2010

I'm not sure what's the question here. You still can do your calculation, save result in Session variable and set this session variable as a default value.
PS. setting a default value for dependent dropdown box doesn't make much sense as this value will be lost once master control value changes.

J
Jay123 author 10/20/2010

Thanks, Sergey.
I was able to resolve it using Javascript.
I have added the following in the HTML editor:

<BODY onload="defval()">

.

.

.

<script>

function defval()

{

document.getElementById("display_value_field2").value='Nice';

}

window.onload=defval;

</script>
When Table A loads up, field2 has a default value of "Nice". This value changes whenever an item is selected on field1. However, field1 is empty when there's no record on Table B.
Idea behind this:

I built a Registration System where Table B is being maintained by my client (the Admin Page). Table A is the actual Registration Page for my client's users. Since Registration info and items change all the time, my client can now do the changes himself (on Table <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=53725&image=1&table=forumreplies' class='bbc_emoticon' alt='B)' /> instead of me changing it in ASP Runner.
Regards,

Jay