Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you get variables onto a form field??? 1

Status
Not open for further replies.

Calbear3

Programmer
Jul 12, 2001
5
US
I'm working on a calendar that is part of a user entry form. (They are entering events for the days.) I am using variables in my script to calculate where the calendar days should fall on the form for the month they have selected. The form has the weekdays across the top Sunday through Saturday and then the squares for each day. The problem is that I want to get the dates that I calculated using variables into the form fields. How do you get derived variables from your script onto a form field???
Thanks!
-Maria
 
I'm terrible sorry Maria, but you have to pull out a better explanation, I really couldn't understand what you want.

Try some examples along the lines or something.


NightWatcher
 
Thanks. I had a feeling no one might understand what I was talking about. I wanted to send a picture of the calendar form but I can't paste or attach it to this, so I'll have to try to describe it. It looks like this:
Sunday | Monday |Tuesday |Wednesday etc.
|__| | |__| ||__| | |__|
Yes * No*| Y* N* |etc. |
--------- ----- |--------|---------


The yes and no are the radio buttons that the users check. Above the yes and no, there is a box which is a form field. I want the right date to appear in that box. (Below is some partial code that leads to that.) The variables work like this: G1 is the value for the Sunday Box (and the name of that form field. G2 is the Monday box, etc.


Select Case whichgrid
Case "wg1"
'First Day of the month is Sunday
G1="1"
G2="2"
G3="3"
G4="4"
G5="5"
G6="6"
G7="7"
Case "wg2"
'First day of the month is Monday
G1="n/a"
G2="1"
G3="2"
G4="3"
G5="4"
G6="5"
G7="6"
Case "wg3"
'First day of the month is Tuesday
G1="n/a"
G2="n/a"
G3="1"
G4="2"
G5="3"
G6="4"
G7="5"
G8="6"
Case "wg4"
'First day of the month is Wednesday
G1="n/a"
G2="n/a"
G3="n/a"
G4="1"
G5="2"
G6="3"
G7="4"
G8=G7+1
Case "wg5"
'First day of the month is Thursday
G1="n/a"
G2="n/a"
G3="n/a"
G4="n/a"
G5="1"
G6="2"
G7="3"
Case "wg6"
'First day of the month is Friday
G1="n/a"
G2="n/a"
G3="n/a"
G4="n/a"
G5="n/a"
G6="1"
G7="2"
Case "wg7"
'First day of the month is Saturday
G1="n/a"
G2="n/a"
G3="n/a"
G4="n/a"
G5="n/a"
G6="n/a"
G7="1"
End Select

Here is the code for the above form field:

'<input type=&quot;text&quot; name=&quot;G1&quot; size=&quot;3&quot; value=Document.Write G1 %>&quot;><input type=&quot;text etc. for G1-G7

The question is: what do I put in VALUE to get the variable value to appear in the form field?

Thanks again.
-Maria
 
Gotcha now.. :)

Okay, I think what you want is something like this:

<%
someVAR = &quot;someVALUE&quot;
%>
<INPUT TYPE=&quot;text&quot; NAME=&quot;G1&quot; SIZE=&quot;3&quot; VALUE=&quot;
<%=someVAR%

>

Remember the file must be .ASP to be parsed as such.

Hope it solves your problem.


NightWatcher
 
Thanks! I would have never figured that out in a million years!! Naturally, this is not documented in any of the milions of vb and asp books I have! It works. Now I have a new problem. The case statement doesn't seem to work with it. No matter what I do, the variables that get loaded to the form fields are always the last ones on the case statement. Here's my code:

Select Case whichgrid
Case &quot;wg1&quot;
'First Day of the month is Sunday
<%G1=&quot;1&quot;
G2=&quot;2&quot;
G3=&quot;3&quot;
G4=&quot;4&quot;
G5=&quot;5&quot;
G6=&quot;6&quot;
G7=&quot;7&quot;%>
Case &quot;wg2&quot;
'First day of the month is Monday
<%G1=&quot;n/a&quot;
G2=&quot;1&quot;
G3=&quot;2&quot;
G4=&quot;3&quot;
G5=&quot;4&quot;
G6=&quot;5&quot;
G7=&quot;6&quot;%>
Case &quot;wg3&quot;
'First day of the month is Tuesday
<%G1=&quot;n/a&quot;
G2=&quot;n/a&quot;
G3=&quot;1&quot;
G4=&quot;2&quot;
G5=&quot;3&quot;
G6=&quot;4&quot;
G7=&quot;5&quot;
G8=&quot;6&quot;%>

etc. etc. etc....
End Select

<input type=&quot;text&quot; name=&quot;G1&quot; size=&quot;3&quot; value=&quot;<%=G1%>&quot;>
<input type=&quot;text&quot; name=&quot;G2&quot; size=&quot;3&quot; value=&quot;<%=G2%>&quot;>
<input type=&quot;text&quot; name=&quot;G3&quot; size=&quot;3&quot; value=&quot;<%=G3%>&quot;>
<input type=&quot;text&quot; name=&quot;G4&quot; size=&quot;3&quot; value=&quot;<%=G4%>&quot;>
<input type=&quot;text&quot; name=&quot;G5&quot; size=&quot;3&quot; value=&quot;<%=G5%>&quot;>
<input type=&quot;text&quot; name=&quot;G6&quot; size=&quot;3&quot; value=&quot;<%=G6%>&quot;>
<input type=&quot;text&quot; name=&quot;G7&quot; size=&quot;3&quot; value=&quot;<%=G7%>&quot;>
<input type=&quot;text&quot; name=&quot;G8&quot; size=&quot;3&quot; value=&quot;<%=G8%>&quot;>


If I put the brackets <% %> around only one case statement, for example Monday, it puts the Monday variables in the right form fields, but the minute I put the brackets in each of the case situations as above, it &quot;falls through&quot; and always inputs the last case situation variables to the form field boxes. In this case, n/a, n/a, 1,2,3,4,5,6
Into the G1 to G8 form fields.

Now what?...

Thanks again! At least now I've advanced to a different problem....
-Maria
 
You don't put the <% %> brackets in the select statement as you've described. Instead:

<%
Select Case whichgrid
Case &quot;wg1&quot;
'First Day of the month is Sunday
G1=&quot;1&quot;
G2=&quot;2&quot;
G3=&quot;3&quot;
G4=&quot;4&quot;
G5=&quot;5&quot;
G6=&quot;6&quot;
G7=&quot;7&quot;
Case &quot;wg2&quot;
'First day of the month is Monday
G1=&quot;n/a&quot;
G2=&quot;1&quot;
G3=&quot;2&quot;
G4=&quot;3&quot;
G5=&quot;4&quot;
G6=&quot;5&quot;
G7=&quot;6&quot;
Case &quot;wg3&quot;
'First day of the month is Tuesday
G1=&quot;n/a&quot;
G2=&quot;n/a&quot;
G3=&quot;1&quot;
G4=&quot;2&quot;
G5=&quot;3&quot;
G6=&quot;4&quot;
G7=&quot;5&quot;
G8=&quot;6&quot;
etc.etc.
End Select
%>

<input type=&quot;text&quot; name=&quot;G1&quot; size=&quot;3&quot; value=&quot;<%=G1%>&quot;>
<input type=&quot;text&quot; name=&quot;G2&quot; size=&quot;3&quot; value=&quot;<%=G2%>&quot;>
<input type=&quot;text&quot; name=&quot;G3&quot; size=&quot;3&quot; value=&quot;<%=G3%>&quot;>
<input type=&quot;text&quot; name=&quot;G4&quot; size=&quot;3&quot; value=&quot;<%=G4%>&quot;>
<input type=&quot;text&quot; name=&quot;G5&quot; size=&quot;3&quot; value=&quot;<%=G5%>&quot;>
<input type=&quot;text&quot; name=&quot;G6&quot; size=&quot;3&quot; value=&quot;<%=G6%>&quot;>
<input type=&quot;text&quot; name=&quot;G7&quot; size=&quot;3&quot; value=&quot;<%=G7%>&quot;>
<input type=&quot;text&quot; name=&quot;G8&quot; size=&quot;3&quot; value=&quot;<%=G8%>&quot;>

This will work fine.

JasonS.
 
Yes, that definitely works! Thanks so very much!!
-Maria
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top