Gar04
asked on
Dynamic Jsp form content Question
hello
i have a form that i am using to present data
that i want the user to pick and on submit send the data to a query
the data being presented by the form is also dynamic (hopefully)
there are three objects on the form i am having bother with that are bond to a recordset
the objects are CycleID | dropdown list of Number type|, Cycle Start |text box of text type| and
Cycle End |text box of type text|
The problem is that i want the user to be able to pick the CycleID number from the dropdown list and have the Cycle start and Cycle End boxes automatically/Dynamically display the corresponding data
i am using dreamweaver
How can i do this????
Gaz
i have a form that i am using to present data
that i want the user to pick and on submit send the data to a query
the data being presented by the form is also dynamic (hopefully)
there are three objects on the form i am having bother with that are bond to a recordset
the objects are CycleID | dropdown list of Number type|, Cycle Start |text box of text type| and
Cycle End |text box of type text|
The problem is that i want the user to be able to pick the CycleID number from the dropdown list and have the Cycle start and Cycle End boxes automatically/Dynamically display the corresponding data
i am using dreamweaver
How can i do this????
Gaz
ASKER
the last two are i.e.
Cycle start and Cycle end
in the database they look like this:
number text text
CycleID CycleStart CycleEnd
1 01/01 14/01
2 15/01 28/01
and so on
i created a recordset from a query that pulls them from the database
so the recordset is available to the page
after that i don't know!
Gaz
Cycle start and Cycle end
in the database they look like this:
number text text
CycleID CycleStart CycleEnd
1 01/01 14/01
2 15/01 28/01
and so on
i created a recordset from a query that pulls them from the database
so the recordset is available to the page
after that i don't know!
Gaz
Using js you'd use something like:
<script language="Javascript">
function change()
{
update your fields appropriately here
}
</script>
<select name="abc" onchange="Javascript:chang e()">
...
<script language="Javascript">
function change()
{
update your fields appropriately here
}
</script>
<select name="abc" onchange="Javascript:chang
...
some other relevant questions:
https://www.experts-exchange.com/questions/20302249/Drop-Down.html
https://www.experts-exchange.com/questions/20746402/How-to-create-a-combo-box-in-jsp.html
https://www.experts-exchange.com/questions/20893929/populate-one-drop-down-based-on-another-drop-down-within-the-same-page.html
https://www.experts-exchange.com/questions/20302249/Drop-Down.html
https://www.experts-exchange.com/questions/20746402/How-to-create-a-combo-box-in-jsp.html
https://www.experts-exchange.com/questions/20893929/populate-one-drop-down-based-on-another-drop-down-within-the-same-page.html
ASKER
Hey i have tried a couple of combinations of this but i am a bit
confused as to where exactly i call the js function
i can't get it to work
can you point me in the right direction??
pls
Gaz
p.s. do i need to change the cycleid name below from "selectCyc1" to "optionValue"???????
this is the dropdown list object that the user changes to effect the
change in the textfield
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>
<select name="selectCyc1" size="1" >
<%
while (rsCyc.next())
{
Object next = rsCyc.getObject("CycleID") ;
String value = (next==null ? "" : next.toString());
%>
<option value="<%= value %>"><%= value %></option>
<%}%>
</select>
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>
This is the form textfield object that i would like to change as the above cycle id number
is changed by the user on the mouse onchange.
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>
<input name="textcyc" type="text" size="20" >
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>
this is the script function to change the value
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>
<SCRIPT LANGUAGE="JavaScript">
function updateText(optionValue) {
textcyc = "Start - End'"
if (optionValue == 1) {
textcyc = "01/01 - 14/01"
}
else if (optionValue == 2) {
textcyc = "15/01 - 28/01"
}
else if (optionValue == 3) {
textcyc = "29/01 - 11/02"
}
else if (optionValue == 4) {
textcyc = "12/02 - 25/02"
}
else if (optionValue == 5) {
textcyc = "26/02 - 11/03"
}
else if (optionValue == 6) {
textcyc = "12/03 - 25/03"
}
else if (optionValue == 7) {
textcyc = "26/03 - 08/04"
}
else if (optionValue == 8) {
textcyc = "09/04 - 22/04"
}
else if (optionValue == 9) {
textcyc = "23/04 - 06/05"
}
else if (optionValue == 10) {
textcyc = "07/05 - 20/05"
}
else if (optionValue == 11) {
textcyc = "21/05 - 03/06"
}
else if (optionValue == 12) {
textcyc = "04/06 - 17/06"
}
else if (optionValue == 13) {
textcyc = "18/06 - 01/07"
}
else if (optionValue == 14) {
textcyc = "02/07 - 15/07"
}
else if (optionValue == 15) {
textcyc = "16/07 - 29/07"
}
else if (optionValue == 16) {
textcyc = "30/07 - 12/08"
}
else if (optionValue == 17) {
textcyc = "13/04 - 26/08"
}
else if (optionValue == 18) {
textcyc = "27/08 - 09/09"
}
else if (optionValue == 19) {
textcyc = "10/09 - 23/09"
}
else if (optionValue == 20) {
textcyc = "24/09 - 07/10"
}
else if (optionValue == 21) {
textcyc = "08/10 - 21/10"
}
else if (optionValue == 22) {
textcyc = "22/10 - 04/11"
}
else if (optionValue == 23) {
textcyc = "05/11 - 18/11"
}
else if (optionValue == 24) {
textcyc = "19/11 - 02/12"
}
else if (optionValue == 25) {
textcyc = "03/12 - 16/12"
}
else if (optionValue == 26) {
textcyc = "17/12 - 31/12"
}
document.all("CycleID").in nerText = text;
}
</SCRIPT>
<P ID="CycleID">This is your initial display.</P>
<FORM><select name="textcyc" onchange="updateText(this. options[th is.selecte dIndex].va lue)">
<option value=1>option1</option><o ption value=2>option2</option><o ption value=3>option 3</option>
<option value=4>option 4</option><option value=5>option 5</option><option value=6>option 6</option>
<option value=7>option 7</option><option value=8>option 8</option><option value=9>option 9</option>
<option value=10>option 10</option><option value=11>option 11</option><option value=12>option 12</option>
<option value=13>option 13</option>option value=14>option 14</option><option value=15>option 15</option>
<option value=16>option 16</option><option value=17>option 17</option><option value=18>option 18</option>
<option value=19>option 19</option><option value=20>option 20</option><option value=21>option 21</option>
<option value=22>option 22</option><option value=23>option 23</option><option value=24>option 24</option>
<option value=25>option 25</option><option value=26>option 26</option>
</select>
</FORM>
confused as to where exactly i call the js function
i can't get it to work
can you point me in the right direction??
pls
Gaz
p.s. do i need to change the cycleid name below from "selectCyc1" to "optionValue"???????
this is the dropdown list object that the user changes to effect the
change in the textfield
>>>>>>>>>>>>>>>>>>>>>>>>>>
<select name="selectCyc1" size="1" >
<%
while (rsCyc.next())
{
Object next = rsCyc.getObject("CycleID")
String value = (next==null ? "" : next.toString());
%>
<option value="<%= value %>"><%= value %></option>
<%}%>
</select>
>>>>>>>>>>>>>>>>>>>>>>>>>>
This is the form textfield object that i would like to change as the above cycle id number
is changed by the user on the mouse onchange.
>>>>>>>>>>>>>>>>>>>>>>>>>>
<input name="textcyc" type="text" size="20" >
>>>>>>>>>>>>>>>>>>>>>>>>>>
this is the script function to change the value
>>>>>>>>>>>>>>>>>>>>>>>>>>
<SCRIPT LANGUAGE="JavaScript">
function updateText(optionValue) {
textcyc = "Start - End'"
if (optionValue == 1) {
textcyc = "01/01 - 14/01"
}
else if (optionValue == 2) {
textcyc = "15/01 - 28/01"
}
else if (optionValue == 3) {
textcyc = "29/01 - 11/02"
}
else if (optionValue == 4) {
textcyc = "12/02 - 25/02"
}
else if (optionValue == 5) {
textcyc = "26/02 - 11/03"
}
else if (optionValue == 6) {
textcyc = "12/03 - 25/03"
}
else if (optionValue == 7) {
textcyc = "26/03 - 08/04"
}
else if (optionValue == 8) {
textcyc = "09/04 - 22/04"
}
else if (optionValue == 9) {
textcyc = "23/04 - 06/05"
}
else if (optionValue == 10) {
textcyc = "07/05 - 20/05"
}
else if (optionValue == 11) {
textcyc = "21/05 - 03/06"
}
else if (optionValue == 12) {
textcyc = "04/06 - 17/06"
}
else if (optionValue == 13) {
textcyc = "18/06 - 01/07"
}
else if (optionValue == 14) {
textcyc = "02/07 - 15/07"
}
else if (optionValue == 15) {
textcyc = "16/07 - 29/07"
}
else if (optionValue == 16) {
textcyc = "30/07 - 12/08"
}
else if (optionValue == 17) {
textcyc = "13/04 - 26/08"
}
else if (optionValue == 18) {
textcyc = "27/08 - 09/09"
}
else if (optionValue == 19) {
textcyc = "10/09 - 23/09"
}
else if (optionValue == 20) {
textcyc = "24/09 - 07/10"
}
else if (optionValue == 21) {
textcyc = "08/10 - 21/10"
}
else if (optionValue == 22) {
textcyc = "22/10 - 04/11"
}
else if (optionValue == 23) {
textcyc = "05/11 - 18/11"
}
else if (optionValue == 24) {
textcyc = "19/11 - 02/12"
}
else if (optionValue == 25) {
textcyc = "03/12 - 16/12"
}
else if (optionValue == 26) {
textcyc = "17/12 - 31/12"
}
document.all("CycleID").in
}
</SCRIPT>
<P ID="CycleID">This is your initial display.</P>
<FORM><select name="textcyc" onchange="updateText(this.
<option value=1>option1</option><o
<option value=4>option 4</option><option value=5>option 5</option><option value=6>option 6</option>
<option value=7>option 7</option><option value=8>option 8</option><option value=9>option 9</option>
<option value=10>option 10</option><option value=11>option 11</option><option value=12>option 12</option>
<option value=13>option 13</option>option value=14>option 14</option><option value=15>option 15</option>
<option value=16>option 16</option><option value=17>option 17</option><option value=18>option 18</option>
<option value=19>option 19</option><option value=20>option 20</option><option value=21>option 21</option>
<option value=22>option 22</option><option value=23>option 23</option><option value=24>option 24</option>
<option value=25>option 25</option><option value=26>option 26</option>
</select>
</FORM>
ASKER
hey
i am not sure how to change the code above to suit my needs
can you help?
gaz
i am not sure how to change the code above to suit my needs
can you help?
gaz
ASKER
this is basically what the form objects look like:
_____ ______
cycle id |_____| dates |_____|
cycle id is a dropdown list with values 1 to 26
when the user selects 1, dates should dynamically display 01/01 - 14/01
when the user selects 2, dates should dynamically display 15/01 - 28/01
and so on
i have tried to implement this by using the code in the last comments but i can't get it to work
pls
help
Gaz
_____ ______
cycle id |_____| dates |_____|
cycle id is a dropdown list with values 1 to 26
when the user selects 1, dates should dynamically display 01/01 - 14/01
when the user selects 2, dates should dynamically display 15/01 - 28/01
and so on
i have tried to implement this by using the code in the last comments but i can't get it to work
pls
help
Gaz
> document.all("CycleID").in nerText = text;
shouldn't that be:
document.all("CycleID").in nerText = textcyc;
shouldn't that be:
document.all("CycleID").in
ASKER
u r right
i spotted that earlier
sorry i had posted that comment first
gaz
i spotted that earlier
sorry i had posted that comment first
gaz
ASKER
how do i tie this function in with the cycleid dropdown list and in turn with the text field???
CycleID List:
<select name="selectcyc" size="1" >
<%
while (rsCyc.next())
{
Object next = rsCyc.getObject("CycleID") ;
String value = (next==null ? "" : next.toString());
%>
<option value="<%= value %>"><%= value %></option>
<%}%>
Text box:
<input name="textfield2" type="text" size="20">
CycleID List:
<select name="selectcyc" size="1" >
<%
while (rsCyc.next())
{
Object next = rsCyc.getObject("CycleID")
String value = (next==null ? "" : next.toString());
%>
<option value="<%= value %>"><%= value %></option>
<%}%>
Text box:
<input name="textfield2" type="text" size="20">
ASKER
the example above gives this
with a <select name, but isn't that only for a list/menu object??
i am a little confused as always!!
<FORM><select name="textcyc" onchange="updateText(this. options[th is.selecte dIndex].va lue)">
<option value=1>option1</option><o ption value=2>option2</option><o ption value=3>option 3</option>
<option value=4>option 4</option><option value=5>option 5</option><option value=6>option 6</option>
<option value=7>option 7</option><option value=8>option 8</option><option value=9>option 9</option>
<option value=10>option 10</option><option value=11>option 11</option><option value=12>option 12</option>
<option value=13>option 13</option>option value=14>option 14</option><option value=15>option 15</option>
<option value=16>option 16</option><option value=17>option 17</option><option value=18>option 18</option>
<option value=19>option 19</option><option value=20>option 20</option><option value=21>option 21</option>
<option value=22>option 22</option><option value=23>option 23</option><option value=24>option 24</option>
<option value=25>option 25</option><option value=26>option 26</option>
</select>
</FORM>
with a <select name, but isn't that only for a list/menu object??
i am a little confused as always!!
<FORM><select name="textcyc" onchange="updateText(this.
<option value=1>option1</option><o
<option value=4>option 4</option><option value=5>option 5</option><option value=6>option 6</option>
<option value=7>option 7</option><option value=8>option 8</option><option value=9>option 9</option>
<option value=10>option 10</option><option value=11>option 11</option><option value=12>option 12</option>
<option value=13>option 13</option>option value=14>option 14</option><option value=15>option 15</option>
<option value=16>option 16</option><option value=17>option 17</option><option value=18>option 18</option>
<option value=19>option 19</option><option value=20>option 20</option><option value=21>option 21</option>
<option value=22>option 22</option><option value=23>option 23</option><option value=24>option 24</option>
<option value=25>option 25</option><option value=26>option 26</option>
</select>
</FORM>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so this is what i did and nothing is working:
<select name="selectcyc" size="1" onchange="updateText(this. options[th is.selecte dIndex].va lue)">
<%
while (rsCyc.next())
{
Object next = rsCyc.getObject("CycleID") ;
String value = (next==null ? "" : next.toString());
%>
<option value="<%= value %>"><%= value %></option>
<%}%>
</select>
and the text field :
<input name="textcyc" type="text" size="20">
<select name="selectcyc" size="1" onchange="updateText(this.
<%
while (rsCyc.next())
{
Object next = rsCyc.getObject("CycleID")
String value = (next==null ? "" : next.toString());
%>
<option value="<%= value %>"><%= value %></option>
<%}%>
</select>
and the text field :
<input name="textcyc" type="text" size="20">
> document.all("CycleID").in nerText = text;
isn't it the textcyc field that you want to set?
isn't it the textcyc field that you want to set?
ASKER
>document.all("CycleID").i
yes, i have changed this already to
document.all("CycleID").in
No thats setting innerText of CycltID, not the input field named 'textcyc'
ASKER
So is this correct?????????:
documents.all("textcyc").i
try something like:
document.form[0].textcyc.v alue = textcyc;
document.form[0].textcyc.v
ASKER
well that seems to work now
thanks a lot
sorry about the confusion
i borrowed and modified the code
i am still a novice but am learning and you guys r a great help
one more question (you don't have to answer this if yu think that it is a seperate issue, i will open another thread and award more points
just let me know)
could i have a similar piece of code that pulls the data from a recordset as opposed to
just typed in values like the last ???????
<SCRIPT LANGUAGE="JavaScript">
function populateField(optionValue) {
textcyc = "locations"
if (optionValue == 1) {
recordset1 >>>>>>>>>>>>> would i have to have code here to access the database and retrieve the results?????
that populates field
}
else if (optionValue == 2) {
recordset2
that populates field
}
else if (optionValue == 3) {
recordset3
that populates field
}
else if (optionValue == 4) {
recordset4
that populates field
}
document.all("locationsfie ld").inner Text = whatever recordset;
}
</SCRIPT>
thanks a lot
sorry about the confusion
i borrowed and modified the code
i am still a novice but am learning and you guys r a great help
one more question (you don't have to answer this if yu think that it is a seperate issue, i will open another thread and award more points
just let me know)
could i have a similar piece of code that pulls the data from a recordset as opposed to
just typed in values like the last ???????
<SCRIPT LANGUAGE="JavaScript">
function populateField(optionValue)
textcyc = "locations"
if (optionValue == 1) {
recordset1 >>>>>>>>>>>>> would i have to have code here to access the database and retrieve the results?????
that populates field
}
else if (optionValue == 2) {
recordset2
that populates field
}
else if (optionValue == 3) {
recordset3
that populates field
}
else if (optionValue == 4) {
recordset4
that populates field
}
document.all("locationsfie
}
</SCRIPT>
javascript runs on the clients, whereas your jsp runs on the server so no you cannot do that.
Instead you would need to load all possible data required from the database (for all options), and have your js display the appropriate data.
I think one of the questions i posted earlier has an example of something similiar.
Instead you would need to load all possible data required from the database (for all options), and have your js display the appropriate data.
I think one of the questions i posted earlier has an example of something similiar.
ASKER
<<<<<<<<document.form[0].t extcyc.val ue = textcyc;
i have four small forms on this page that i hope can all use this
if i change it to the above will it effect the forms at all??
gaz
i have four small forms on this page that i hope can all use this
if i change it to the above will it effect the forms at all??
gaz
give your forms names and use:
document.formname.textcyc. value = textcyc;
or pass the form to the js function.
document.formname.textcyc.
or pass the form to the js function.
ASKER
cheers for the
answer
i don't think that i will attempt to implement that just yet
i should know enough by now to know that js is client side and jsp server
i was just curious
there is just too much data to do that the way you just showed me and i was wondering if there is another way
i will check out those examples
thanks again
i will send your points in a mo
Gaz
answer
i don't think that i will attempt to implement that just yet
i should know enough by now to know that js is client side and jsp server
i was just curious
there is just too much data to do that the way you just showed me and i was wondering if there is another way
i will check out those examples
thanks again
i will send your points in a mo
Gaz
ASKER
excellent
cheers again
gaz
cheers again
gaz
> i was wondering if there is another way
another way would be to submit the form whenever an option selected.
another way would be to submit the form whenever an option selected.
Or use some javascript to fill in the values.
Are the vlues available on the page?