Results 1 to 3 of 3

Thread: asp-javascript

  1. #1
    Join Date
    Nov 2004

    Unanswered: asp-javascript

    I am creating many text boxes by doing:
    <% for i=1 to 9 %>
    <INPUT TYPE="text" VALUE="5" NAME="dbh<%=i%>2">
    <% Next %>
    and then in my javascript function I want to assign values to these text boxes;
    for (s = 1; s <= 9; s++) {
    document.t3.f.value= s;
    but the above function does not work..
    I tried
    var tk="t3.dbh12";

    but that does not work either!
    Does anybody know how I can write the javascript function?

  2. #2
    Join Date
    May 2004
    Do a search for the javascript function eval. That will help you to create javascript that will access dynamic objects.


  3. #3
    Join Date
    Aug 2004
    it looks like you are mixing up client side and server side javascript.
    If you want to build form elements dynamically you would use only server side javascript and html:

    <%//server side javascript
    //loop and create a text field on each loop

    //declare the f variable and store the new field name for each loop
    var f;

    for (s = 1; s <= 9; s++) {
    //change the name of f at each loop
    //now we are ready to build the html, lets close the server side asp tag and switch to html


    <p><INPUT TYPE="text" VALUE="value goes here" NAME="<% = f %>"></P>

    //now we are back server side and close the loop
    //end of script


    This should do it, not that you should do this within the body of your page where you want to form elements to go.
    Hope this helps,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts