If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > asp-javascript

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-16-04, 14:34
cursavas cursavas is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
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++) {
f="dbh"+s+"2"
document.t3.f.value= s;
}
--------------------------
but the above function does not work..
I tried
var tk="t3.dbh12";
document[tk].value;

but that does not work either!
Does anybody know how I can write the javascript function?
Reply With Quote
  #2 (permalink)  
Old 12-17-04, 09:25
DMWCincy DMWCincy is offline
Registered User
 
Join Date: May 2004
Posts: 125
Do a search for the javascript function eval. That will help you to create javascript that will access dynamic objects.

http://builder.com.com/5100-6371-5169823.html

HTH
Jeff
Reply With Quote
  #3 (permalink)  
Old 12-20-04, 06:43
oliflorence oliflorence is offline
Registered User
 
Join Date: Aug 2004
Posts: 96
Hi,
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
f="dbh"+s+"2";
//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,
Regards,
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On