Remote scripting with IFRAME or LAYER

by Jan Verhoeven, 16 November 2001

Using a hidden IFRAME or LAYER tag you can do remote scripting. It is my preferred way of handling user input in an ASP application.

  1. Submit the data to an ASP page with the IFRAME (or LAYER) as the target.
  2. In the onLoad event of the resulting page that is loaded in the IFRAME perform any updating of the calling HTML page, using javascript and DHTML.

Why use remote scripting?

There are many advantages in using remote scripting:

  1. No need to reload the page. This is especially important when you have a huge page.
  2. Improved user experience. The user can change text in a textbox, hit the enter key and presto, the data is updated silently.

Custom attributes

Using IE you can add your own custom attributes to an html tag. If for instance you have a select list with option elements you can do things like:

<option value='<%=id_question%>' ref_user='<%=id_user%>' ref_survey='<%=id_survey%>'><%=strQuestion%></option>

In your script you then get a reference to the selected option and can retrieve the values of the required attributes, including the custom ones.

id_question=opt.value
ref_user=opt.ref_user
ref_survey=opt.ref_survey
strQuestion=opt.text

There is really no limit with what you can do using remote scripting.