sending windows.document.form.item.value properties into functions
Author |
Message |
Matt Suderma #1 / 25
|
 sending windows.document.form.item.val ue properties into functions
I don't get it. I'm running a very simple test app where I'm trying to use the "document.form.item.value" property. On line 15 I have a select with 3 options, the onclick is supposed to change the value of another input item in the form, by equating it to a function call, sending the value of the clicked option. On line 8 I have the exact same select. The only difference is the input item on the form is update with the value directly, no function call. Line 8's onclick works like a champ Line 15's gives me an error "Error: Object expected" The function works fine, on line ref: 28, I send in a value and get a good return. I am really confused. I think I'm doing everything right. What am I missing? Thanks in advance, Matt ______________________ 1. function Newtext(ByVal Ncase) 2. Newtext="NewCase: " & cstr(Ncase) 3. end function 4. test=2 5. %> 6. 7. <form name="caselist"> 8. <p><select name="cases" size="5" onclick="window.document.caselist.displayed.value=window.document.caselist.c ases.value"> 10. <option value="1">1</option> 11. <option value="2">2</option> 12. <option value="2">3</option> 13. </select></p> 14. <p> 15. <p><select name="caseselect" size="5" onclick="window.document.caselist.displayed.value=newtext(window.document.ca selist.caseselect.value)"> 16. <option value="1">1</option> 17. <option value="2">2</option> 18. <option value="2">3</option> 19. </select></p> 20. <p> 21. <input type="button" value="Button" name="B1" 22. onclick="window.document.caselist.displayed.value=window.document.caselist.c aseselect.value"></p> 23. <p> 24. <textarea rows="6" name="displayed" cols="44"> 25. onclick text should bo here 26. </textarea></p> 27. 28. <%=newtext(test)%> 29. </form>
|
Thu, 13 Dec 2001 03:00:00 GMT |
|
 |
Michael Harri #2 / 25
|
 sending windows.document.form.item.val ue properties into functions
You aren't sending back a client-side <script> element in the HTML that defines the function NewTest to the client... Use "View source" to look at the HTML sent to the browser ... -- Michael Harris
| I don't get it. I'm running a very simple test app where I'm trying to use | the "document.form.item.value" property. | | On line 15 I have a select with 3 options, the onclick is supposed to change | the value of another input item in the form, by equating it to a function | call, sending the value of the clicked option. | | On line 8 I have the exact same select. The only difference is the input | item on the form is update with the value directly, no function call. | | Line 8's onclick works like a champ | Line 15's gives me an error "Error: Object expected" | | The function works fine, on line ref: 28, I send in a value and get a good | return. | | I am really confused. I think I'm doing everything right. What am I | missing? | | Thanks in advance, | Matt | ______________________ | 1. function Newtext(ByVal Ncase) | 2. Newtext="NewCase: " & cstr(Ncase) | 3. end function | 4. test=2 | 5. %> | 6. | 7. <form name="caselist"> | 8. <p><select name="cases" size="5" | onclick="window.document.caselist.displayed.value=window.document.caselist.c | ases.value"> | 10. <option value="1">1</option> | 11. <option value="2">2</option> | 12. <option value="2">3</option> | 13. </select></p> | 14. <p> | | 15. <p><select name="caseselect" size="5" | onclick="window.document.caselist.displayed.value=newtext(window.document.ca | selist.caseselect.value)"> | 16. <option value="1">1</option> | 17. <option value="2">2</option> | 18. <option value="2">3</option> | 19. </select></p> | 20. <p> | 21. <input type="button" value="Button" name="B1" | 22. | onclick="window.document.caselist.displayed.value=window.document.caselist.c | aseselect.value"></p> | 23. <p> | 24. <textarea rows="6" name="displayed" cols="44"> | 25. onclick text should bo here | 26. </textarea></p> | 27. | 28. <%=newtext(test)%> | 29. </form> | | |
|
Fri, 14 Dec 2001 03:00:00 GMT |
|
 |
Matt Suderma #3 / 25
|
 sending windows.document.form.item.val ue properties into functions
isn't that what lines 1,2,3 are? Quote:
>You aren't sending back a client-side <script> element in the HTML that >defines the function NewTest to the client... >Use "View source" to look at the HTML sent to the browser ... >-- >Michael Harris
>| I don't get it. I'm running a very simple test app where I'm trying to >use >| the "document.form.item.value" property. >| >| On line 15 I have a select with 3 options, the onclick is supposed to >change >| the value of another input item in the form, by equating it to a function >| call, sending the value of the clicked option. >| >| On line 8 I have the exact same select. The only difference is the input >| item on the form is update with the value directly, no function call. >| >| Line 8's onclick works like a champ >| Line 15's gives me an error "Error: Object expected" >| >| The function works fine, on line ref: 28, I send in a value and get a good >| return. >| >| I am really confused. I think I'm doing everything right. What am I >| missing? >| >| Thanks in advance, >| Matt >| ______________________ >| 1. function Newtext(ByVal Ncase) >| 2. Newtext="NewCase: " & cstr(Ncase) >| 3. end function >| 4. test=2 >| 5. %> >| 6. >| 7. <form name="caselist"> >| 8. <p><select name="cases" size="5" >| >onclick="window.document.caselist.displayed.value=window.document.caselist. c >| ases.value"> >| 10. <option value="1">1</option> >| 11. <option value="2">2</option> >| 12. <option value="2">3</option> >| 13. </select></p> >| 14. <p> >| >| 15. <p><select name="caseselect" size="5" >| >onclick="window.document.caselist.displayed.value=newtext(window.document.c a >| selist.caseselect.value)"> >| 16. <option value="1">1</option> >| 17. <option value="2">2</option> >| 18. <option value="2">3</option> >| 19. </select></p> >| 20. <p> >| 21. <input type="button" value="Button" name="B1" >| 22. >| >onclick="window.document.caselist.displayed.value=window.document.caselist. c >| aseselect.value"></p> >| 23. <p> >| 24. <textarea rows="6" name="displayed" cols="44"> >| 25. onclick text should bo here >| 26. </textarea></p> >| 27. >| 28. <%=newtext(test)%> >| 29. </form> >| >| >|
|
Fri, 14 Dec 2001 03:00:00 GMT |
|
 |
Michael Harri #4 / 25
|
 sending windows.document.form.item.val ue properties into functions
What you posted doesn't look like the entire ASP page... | >| 1. function NewText(ByVal Ncase) | >| 2. Newtext="NewCase: " & cstr(Ncase) | >| 3. end function | >| 4. test=2 | >| 5. %> Lime 5 suggests to me that there's more above line 1 here, in particular the opening <% for a server-side block of script code. What you need to do is send back as part of the HTML page a script element that defines the NewText function, usually located within the <head>...</head> element. <html> <head> ... ... <script language="VBScript"> function Newtext(ByVal Ncase) Newtext="NewCase: " & cstr(Ncase) end function </script> </head> ... <body> ... <form name="blahblah... > ... </form> </body> </html> When you "View Source" from the browser, you won't see <script> elements that are in the head. You _could_ put the <script> element inside the <body> so you can see it with "View Source" but the browser can "see" it (and use it) no matter where in the page you place it. It's just good practice to it in the <head> or at the top of the <body> to ensure that the event handlers are parsed and ready before the elements whose events they are going to "handle" are visible for the user to interact with. -- Michael Harris
| isn't that what lines 1,2,3 are? |
| >You aren't sending back a client-side <script> element in the HTML that | >defines the function NewTest to the client... | > | >Use "View source" to look at the HTML sent to the browser ... | > | >-- | >Michael Harris | > | >
| >| I don't get it. I'm running a very simple test app where I'm trying to | >use | >| the "document.form.item.value" property. | >| | >| On line 15 I have a select with 3 options, the onclick is supposed to | >change | >| the value of another input item in the form, by equating it to a function | >| call, sending the value of the clicked option. | >| | >| On line 8 I have the exact same select. The only difference is the input | >| item on the form is update with the value directly, no function call. | >| | >| Line 8's onclick works like a champ | >| Line 15's gives me an error "Error: Object expected" | >| | >| The function works fine, on line ref: 28, I send in a value and get a | good | >| return. | >| | >| I am really confused. I think I'm doing everything right. What am I | >| missing? | >| | >| Thanks in advance, | >| Matt | >| ______________________ | >| 1. function Newtext(ByVal Ncase) | >| 2. Newtext="NewCase: " & cstr(Ncase) | >| 3. end function | >| 4. test=2 | >| 5. %> | >| 6. | >| 7. <form name="caselist"> | >| 8. <p><select name="cases" size="5" | >| | Quote: >onclick="window.document.caselist.displayed.value=window.document.caselist.
| c | >| ases.value"> | >| 10. <option value="1">1</option> | >| 11. <option value="2">2</option> | >| 12. <option value="2">3</option> | >| 13. </select></p> | >| 14. <p> | >| | >| 15. <p><select name="caseselect" size="5" | >| | Quote: >onclick="window.document.caselist.displayed.value=newtext(window.document.c
| a | >| selist.caseselect.value)"> | >| 16. <option value="1">1</option> | >| 17. <option value="2">2</option> | >| 18. <option value="2">3</option> | >| 19. </select></p> | >| 20. <p> | >| 21. <input type="button" value="Button" name="B1" | >| 22. | >| | Quote: >onclick="window.document.caselist.displayed.value=window.document.caselist.
| c | >| aseselect.value"></p> | >| 23. <p> | >| 24. <textarea rows="6" name="displayed" cols="44"> | >| 25. onclick text should bo here | >| 26. </textarea></p> | >| 27. | >| 28. <%=newtext(test)%> | >| 29. </form> | >| | >| | >| | > | > | |
|
Fri, 14 Dec 2001 03:00:00 GMT |
|
 |
Tony #5 / 25
|
 sending windows.document.form.item.val ue properties into functions
Quote: > When you "View Source" from the browser, you won't see <script> elements > that are in the head. You _could_ put the <script> element inside the > <body> so you can see it with "View Source" but the browser can "see" it > (and use it) no matter where in the page you place it.
I belief you may be a bit off with that statement, however I may be wrong. It being in the head doesn't stop it from being viewed by 'view source' . It is gone because it is ran on the server. i.e. between <%%> delimiters or it was placed in a run at server script tag. Otherwise it is always viewable regardless if where it is placed. Quote: >It's just good > practice to it in the <head> or at the top of the <body> to ensure that the > event handlers are parsed and ready before the elements whose events they > are going to "handle" are visible for the user to interact with.
Script should be in the head, (see http://msdn.microsoft.com/scripting/vbscript/techinfo/vbsfaq.htm Where should my script be within the document? ). If it is not in a sub or function and references an object it does need to be placed after the object on the page. Code can not call or reference an object if it has not been created by the browser. So I usually place that kind of script right before the closing body tag. -- Regards, Tony Developer/designer/all around good guy www.csofm.com We specialize in Medical and Construction office solutions Come see the last best place, BillingsDINE www.csofm.com/blgsdine/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Fri, 14 Dec 2001 03:00:00 GMT |
|
 |
Michael Harri #6 / 25
|
 sending windows.document.form.item.val ue properties into functions
duh! I must have had one too many Jolt Colas when I made that statement about the visibility of script elements within the <head>, as Tony astutely pointed out. And I should have also clarified (again as Tony did) that the <head> is the best place for the code with the obvious exception of inline <script> blocks that are meant to do things like document.write's or interact with <object> elements (like loading an ActiveX ListView control) as the page is built. -- Michael Harris
| > When you "View Source" from the browser, you won't see <script> elements | > that are in the head. You _could_ put the <script> element inside the | > <body> so you can see it with "View Source" but the browser can "see" it | > (and use it) no matter where in the page you place it. | | I belief you may be a bit off with that statement, however I may be wrong. | It being in the head doesn't stop it from being viewed by 'view source' . | It is gone because it is ran on the server. i.e. between <%%> delimiters | or it was placed in a run at server script tag. Otherwise it is always | viewable regardless if where it is placed. | | >It's just good | > practice to it in the <head> or at the top of the <body> to ensure that | the | > event handlers are parsed and ready before the elements whose events they | > are going to "handle" are visible for the user to interact with. | > | > | | Script should be in the head, (see | http://msdn.microsoft.com/scripting/vbscript/techinfo/vbsfaq.htm | Where should my script be within the document? ). | If it is not in a sub or function and references an object it does need to | be placed after the object on the page. Code can not call or reference an | object if it has not been created by the browser. So I usually place that | kind of script right before the closing body tag. | | -- | Regards, | Tony | Developer/designer/all around good guy | www.csofm.com | We specialize in Medical and Construction office solutions | | Come see the last best place, BillingsDINE | www.csofm.com/blgsdine/ | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
|
Fri, 14 Dec 2001 03:00:00 GMT |
|
 |
Matt Suderma #7 / 25
|
 sending windows.document.form.item.val ue properties into functions
OK..you're right. There's alot more going on above this. My code might not be politically correct. To be honest, I'm the only one who really uses this page so I'm not really concerned about people viewing the source. Thank you for the advice though. My crappy coding practices asside. As long as the call for the function happens after the function is define, which is the case here, then I should be able to send the value of the select into the function, which resets the value of the textarea.....why won't this work? Quote:
>What you posted doesn't look like the entire ASP page... >| >| 1. function NewText(ByVal Ncase) >| >| 2. Newtext="NewCase: " & cstr(Ncase) >| >| 3. end function >| >| 4. test=2 >| >| 5. %> >Lime 5 suggests to me that there's more above line 1 here, in particular the >opening <% for a server-side block of script code. >What you need to do is send back as part of the HTML page a script element >that defines the NewText function, usually located within the ><head>...</head> element. ><html> ><head> >... >... ><script language="vbscript"> >function Newtext(ByVal Ncase) >Newtext="NewCase: " & cstr(Ncase) >end function ></script> ></head> >... ><body> >... ><form name="blahblah... > >... ></form> ></body> ></html> >When you "View Source" from the browser, you won't see <script> elements >that are in the head. You _could_ put the <script> element inside the ><body> so you can see it with "View Source" but the browser can "see" it >(and use it) no matter where in the page you place it. It's just good >practice to it in the <head> or at the top of the <body> to ensure that the >event handlers are parsed and ready before the elements whose events they >are going to "handle" are visible for the user to interact with. >-- >Michael Harris
>| isn't that what lines 1,2,3 are? >|
>| >You aren't sending back a client-side <script> element in the HTML that >| >defines the function NewTest to the client... >| > >| >Use "View source" to look at the HTML sent to the browser ... >| > >| >-- >| >Michael Harris >| > >| >
>| >| I don't get it. I'm running a very simple test app where I'm trying to >| >use >| >| the "document.form.item.value" property. >| >| >| >| On line 15 I have a select with 3 options, the onclick is supposed to >| >change >| >| the value of another input item in the form, by equating it to a >function >| >| call, sending the value of the clicked option. >| >| >| >| On line 8 I have the exact same select. The only difference is the >input >| >| item on the form is update with the value directly, no function call. >| >| >| >| Line 8's onclick works like a champ >| >| Line 15's gives me an error "Error: Object expected" >| >| >| >| The function works fine, on line ref: 28, I send in a value and get a >| good >| >| return. >| >| >| >| I am really confused. I think I'm doing everything right. What am I >| >| missing? >| >| >| >| Thanks in advance, >| >| Matt >| >| ______________________ >| >| 1. function Newtext(ByVal Ncase) >| >| 2. Newtext="NewCase: " & cstr(Ncase) >| >| 3. end function >| >| 4. test=2 >| >| 5. %> >| >| 6. >| >| 7. <form name="caselist"> >| >| 8. <p><select name="cases" size="5" >| >| >| >>onclick="window.document.caselist.displayed.value=window.document.caselist . >| c >| >| ases.value"> >| >| 10. <option value="1">1</option> >| >| 11. <option value="2">2</option> >| >| 12. <option value="2">3</option> >| >| 13. </select></p> >| >| 14. <p> >| >| >| >| 15. <p><select name="caseselect" size="5" >| >| >| >>onclick="window.document.caselist.displayed.value=newtext(window.document. c >| a >| >| selist.caseselect.value)"> >| >| 16. <option value="1">1</option> >| >| 17. <option value="2">2</option> >| >| 18. <option value="2">3</option> >| >| 19. </select></p> >| >| 20. <p> >| >| 21. <input type="button" value="Button" name="B1" >| >| 22. >| >| >| >>onclick="window.document.caselist.displayed.value=window.document.caselist . >| c >| >| aseselect.value"></p> >| >| 23. <p> >| >| 24. <textarea rows="6" name="displayed" cols="44"> >| >| 25. onclick text should bo here >| >| 26. </textarea></p> >| >| 27. >| >| 28. <%=newtext(test)%> >| >| 29. </form> >| >| >| >| >| >| >| > >| > >| >|
|
Sat, 15 Dec 2001 03:00:00 GMT |
|
 |
#8 / 25
|
 sending windows.document.form.item.val ue properties into functions
|
Fri, 19 Jun 1992 00:00:00 GMT |
|
 |
Matt Suderma #9 / 25
|
 sending windows.document.form.item.val ue properties into functions
This is the whole page. If you copy this and run it....I'm sure the problem will become clear. And by the way, honestly, thank you for your help. This just doesn't seem to be working like it should. I SHOULD be able to do this. Shouldn't I? <html> <head> <title>New Page 1</title> <meta name="GENERATOR" content="Microsoft FrontPage 3.0"> </head> <body> <% function Newtext(ByVal Ncase) Newtext="NewCase: " & cstr(Ncase) end function test=2 %> <form name="caselist"> <p>Case Select #1: equates the value of Displayed with it's own value<br> <select name="cases" size="5" onclick="window.document.caselist.displayed.value=window.document.caselist.c ases.value"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select></p> <p>Case Select #2: equates the value of Displayed with sending it's own value into the function <br> <select name="caseselect" size="5" onclick="window.document.caselist.displayed.value=newtext(window.document.ca selist.caseselect.value)"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select></p> <p>this button equates Displayed value with the value of CS #2. <input type="button" value="Button" name="B1" onclick="window.document.caselist.displayed.value=window.document.caselist.c aseselect.value"><br> This button equates Displayed value with sending the value of CS #2 to the function.<input type="button" value="Button" name="B1" onclick="window.document.caselist.displayed.value=Newtext(window.document.ca selist.caseselect.value)"></p> <p>Displayed<br> <textarea rows="6" name="displayed" cols="44"> onclick text should bo here </textarea></p> <%=newtext(test)%> </form> </body> </html>
|
Sat, 15 Dec 2001 03:00:00 GMT |
|
 |
#10 / 25
|
 sending windows.document.form.item.val ue properties into functions
|
Fri, 19 Jun 1992 00:00:00 GMT |
|
 |
Tony #11 / 25
|
 sending windows.document.form.item.val ue properties into functions
Please don't think I'm being rude, but just what are you attempting to accomplish? Are you wanting to populate items/values in select 2 based on a value from select 1? If that is the case I believe you need to submit the form to itself when the onChange fires. If that is the case I can post an example. -- Regards, Tony Developer/designer/all around good guy www.csofm.com We specialize in Medical and Construction office/web solutions Come see the last best place, BillingsDINE www.csofm.com/blgsdine/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quote: > OK..you're right. There's alot more going on above this. My code might > not be politically correct. To be honest, I'm the only one who really uses > this page so I'm not really concerned about people viewing the source. > Thank you for the advice though. > My crappy coding practices asside. As long as the call for the function > happens after the function is define, which is the case here, then I should > be able to send the value of the select into the function, which resets the > value of the textarea.....why won't this work?
> >What you posted doesn't look like the entire ASP page... > >| >| 1. function NewText(ByVal Ncase) > >| >| 2. Newtext="NewCase: " & cstr(Ncase) > >| >| 3. end function > >| >| 4. test=2 > >| >| 5. %> > >Lime 5 suggests to me that there's more above line 1 here, in particular > the > >opening <% for a server-side block of script code. > >What you need to do is send back as part of the HTML page a script element > >that defines the NewText function, usually located within the > ><head>...</head> element. > ><html> > ><head> > >... > >... > ><script language="vbscript"> > >function Newtext(ByVal Ncase) > >Newtext="NewCase: " & cstr(Ncase) > >end function > ></script> > ></head> > >... > ><body> > >... > ><form name="blahblah... > > >... > ></form> > ></body> > ></html> > >When you "View Source" from the browser, you won't see <script> elements > >that are in the head. You _could_ put the <script> element inside the > ><body> so you can see it with "View Source" but the browser can "see" it > >(and use it) no matter where in the page you place it. It's just good > >practice to it in the <head> or at the top of the <body> to ensure that the > >event handlers are parsed and ready before the elements whose events they > >are going to "handle" are visible for the user to interact with. > >-- > >Michael Harris
> >| isn't that what lines 1,2,3 are? > >|
> >| >You aren't sending back a client-side <script> element in the HTML that > >| >defines the function NewTest to the client... > >| > > >| >Use "View source" to look at the HTML sent to the browser ... > >| > > >| >-- > >| >Michael Harris > >| > > >| >
> >| >| I don't get it. I'm running a very simple test app where I'm trying > to > >| >use > >| >| the "document.form.item.value" property. > >| >| > >| >| On line 15 I have a select with 3 options, the onclick is supposed to > >| >change > >| >| the value of another input item in the form, by equating it to a > >function > >| >| call, sending the value of the clicked option. > >| >| > >| >| On line 8 I have the exact same select. The only difference is the > >input > >| >| item on the form is update with the value directly, no function call. > >| >| > >| >| Line 8's onclick works like a champ > >| >| Line 15's gives me an error "Error: Object expected" > >| >| > >| >| The function works fine, on line ref: 28, I send in a value and get a > >| good > >| >| return. > >| >| > >| >| I am really confused. I think I'm doing everything right. What am I > >| >| missing? > >| >| > >| >| Thanks in advance, > >| >| Matt > >| >| ______________________ > >| >| 1. function Newtext(ByVal Ncase) > >| >| 2. Newtext="NewCase: " & cstr(Ncase) > >| >| 3. end function > >| >| 4. test=2 > >| >| 5. %> > >| >| 6. > >| >| 7. <form name="caselist"> > >| >| 8. <p><select name="cases" size="5" > >| >| > >| >>onclick="window.document.caselist.displayed.value=window.document.caselist > . > >| c > >| >| ases.value"> > >| >| 10. <option value="1">1</option> > >| >| 11. <option value="2">2</option> > >| >| 12. <option value="2">3</option> > >| >| 13. </select></p> > >| >| 14. <p> > >| >| > >| >| 15. <p><select name="caseselect" size="5" > >| >| > >| >>onclick="window.document.caselist.displayed.value=newtext(window.document. > c > >| a > >| >| selist.caseselect.value)"> > >| >| 16. <option value="1">1</option> > >| >| 17. <option value="2">2</option> > >| >| 18. <option value="2">3</option> > >| >| 19. </select></p> > >| >| 20. <p> > >| >| 21. <input type="button" value="Button" name="B1" > >| >| 22. > >| >| > >| >>onclick="window.document.caselist.displayed.value=window.document.caselist > . > >| c > >| >| aseselect.value"></p> > >| >| 23. <p> > >| >| 24. <textarea rows="6" name="displayed" cols="44"> > >| >| 25. onclick text should bo here > >| >| 26. </textarea></p> > >| >| 27. > >| >| 28. <%=newtext(test)%> > >| >| 29. </form> > >| >| > >| >| > >| >| > >| > > >| > > >| > >|
|
Sat, 15 Dec 2001 03:00:00 GMT |
|
 |
#12 / 25
|
 sending windows.document.form.item.val ue properties into functions
|
Fri, 19 Jun 1992 00:00:00 GMT |
|
 |
Tony #13 / 25
|
 sending windows.document.form.item.val ue properties into functions
Quote: > <% > function Newtext(ByVal Ncase) > Newtext="NewCase: " & cstr(Ncase) > end function > test=2 > %>
To begin with this runs on the server and long since done and gone by the time the browser renders the source. Code between the <%%> delimiters runs on the server. If you want to call a function it needs to be in script tags in the head. That is what Michael and I were talking about. Here's a simple example of how to populate option values in a select based on a value from another select.. Very simple, but can be built on. <% if request.form("combo1") <> "" then val1 = "doIt" if request.form("combo1") = "okay" then val2 = "1" val3 = "2" elseif request.form("combo1") = "notOkay" then val2 = "3" val3 = "4" end if end if %> <html> <head> <title>This form submits to itself</title> </head> <body BGCOLOR="#008000" TEXT="#000000"> If you have asp this form will change based of the value selected. First select okay from the top select, then select notOkay, it will change the value of the second select. I hope this helps. Good luck!!!!! <p> <form ACTION="selfform.asp" METHOD="POST" name="form1"> <select NAME="combo1" onChange="form1.submit()"> <option value="">Pick one <option value="okay">Okay <option value="notOkay">Not okay </select><br> <% if val1 = "doIt" then %> <select NAME="combo2"> <option value="<%= val2 %>"><%= val2 %> <option value="<%= val3 %>"><%= val3 %> </select> <br> <% end if %> </form> </body> </html> If hope this helps. -- Regards, Tony Developer/designer/all around good guy www.csofm.com We specialize in Medical and Construction office/web solutions Come see the last best place, BillingsDINE www.csofm.com/blgsdine/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Sat, 15 Dec 2001 03:00:00 GMT |
|
 |
#14 / 25
|
 sending windows.document.form.item.val ue properties into functions
|
Fri, 19 Jun 1992 00:00:00 GMT |
|
 |
Matt Suderma #15 / 25
|
 sending windows.document.form.item.val ue properties into functions
Good catch Tony, but submitting the form to itself is exactly what I'm trying to avoid. This is an example of something I'm trying to do in a much more complicated page that takes 10-15 seconds to load. Part of this page is a simple refresh based on a select value. I hate having to reload this page. If I could write a function that would refresh a field based on the value of the select, the page will run much more efficiently. What I don't understand is: I can do a field refresh based on the value of a select, which is basically a text string. Why can't I do a field refresh based on a function call with sends back a text string? Logically, they are the same. Since that post, I did another test. A button's onclick equated the value of the display with a call the the function sending a raw value. <input type="button" value="Button" name="B1" onclick="window.document.caselist.displayed.value=Newtext(2)"> I tried this many ways, in quotes, changing the function to expect a ByVal, then ByRef. In all cases I got the same error: Error: Object Expected. I don't GET it..... Quote:
>Please don't think I'm being rude, but just what are you attempting to >accomplish? >Are you wanting to populate items/values in select 2 based on a value from >select 1? If that is the case I believe you need to submit the form to >itself when the onChange fires. If that is the case I can post an example. >-- >Regards, >Tony >Developer/designer/all around good guy >www.csofm.com >We specialize in Medical and Construction office/web solutions >Come see the last best place, BillingsDINE >www.csofm.com/blgsdine/ >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> OK..you're right. There's alot more going on above this. My code might >> not be politically correct. To be honest, I'm the only one who really >uses >> this page so I'm not really concerned about people viewing the source. >> Thank you for the advice though. >> My crappy coding practices asside. As long as the call for the function >> happens after the function is define, which is the case here, then I >should >> be able to send the value of the select into the function, which resets >the >> value of the textarea.....why won't this work?
>> >What you posted doesn't look like the entire ASP page... >> >| >| 1. function NewText(ByVal Ncase) >> >| >| 2. Newtext="NewCase: " & cstr(Ncase) >> >| >| 3. end function >> >| >| 4. test=2 >> >| >| 5. %> >> >Lime 5 suggests to me that there's more above line 1 here, in particular >> the >> >opening <% for a server-side block of script code. >> >What you need to do is send back as part of the HTML page a script >element >> >that defines the NewText function, usually located within the >> ><head>...</head> element. >> ><html> >> ><head> >> >... >> >... >> ><script language="vbscript"> >> >function Newtext(ByVal Ncase) >> >Newtext="NewCase: " & cstr(Ncase) >> >end function >> ></script> >> ></head> >> >... >> ><body> >> >... >> ><form name="blahblah... > >> >... >> ></form> >> ></body> >> ></html> >> >When you "View Source" from the browser, you won't see <script> elements >> >that are in the head. You _could_ put the <script> element inside the >> ><body> so you can see it with "View Source" but the browser can "see" it >> >(and use it) no matter where in the page you place it. It's just good >> >practice to it in the <head> or at the top of the <body> to ensure that >the >> >event handlers are parsed and ready before the elements whose events they >> >are going to "handle" are visible for the user to interact with. >> >-- >> >Michael Harris
>> >| isn't that what lines 1,2,3 are? >> >|
>> >| >You aren't sending back a client-side <script> element in the HTML >that >> >| >defines the function NewTest to the client... >> >| > >> >| >Use "View source" to look at the HTML sent to the browser ... >> >| > >> >| >-- >> >| >Michael Harris >> >| > >> >| >
>> >| >| I don't get it. I'm running a very simple test app where I'm trying >> to >> >| >use >> >| >| the "document.form.item.value" property. >> >| >| >> >| >| On line 15 I have a select with 3 options, the onclick is supposed >to >> >| >change >> >| >| the value of another input item in the form, by equating it to a >> >function >> >| >| call, sending the value of the clicked option. >> >| >| >> >| >| On line 8 I have the exact same select. The only difference is the >> >input >> >| >| item on the form is update with the value directly, no function >call. >> >| >| >> >| >| Line 8's onclick works like a champ >> >| >| Line 15's gives me an error "Error: Object expected" >> >| >| >> >| >| The function works fine, on line ref: 28, I send in a value and get >a >> >| good >> >| >| return. >> >| >| >> >| >| I am really confused. I think I'm doing everything right. What am >I >> >| >| missing? >> >| >| >> >| >| Thanks in advance, >> >| >| Matt >> >| >| ______________________ >> >| >| 1. function Newtext(ByVal Ncase) >> >| >| 2. Newtext="NewCase: " & cstr(Ncase) >> >| >| 3. end function >> >| >| 4. test=2 >> >| >| 5. %> >> >| >| 6. >> >| >| 7. <form name="caselist"> >> >| >| 8. <p><select name="cases" size="5" >> >| >| >> >| >>>onclick="window.document.caselist.displayed.value=window.document.caselis t >> . >> >| c >> >| >| ases.value"> >> >| >| 10. <option value="1">1</option> >> >| >| 11. <option value="2">2</option> >> >| >| 12. <option value="2">3</option> >> >| >| 13. </select></p> >> >| >| 14. <p> >> >| >| >> >| >| 15. <p><select name="caseselect" size="5" >> >| >| >> >| >>>onclick="window.document.caselist.displayed.value=newtext(window.document . >> c >> >| a >> >| >| selist.caseselect.value)"> >> >| >| 16. <option value="1">1</option> >> >| >| 17. <option value="2">2</option> >> >| >| 18. <option value="2">3</option> >> >| >| 19. </select></p> >> >| >| 20. <p> >> >| >| 21. <input type="button" value="Button" name="B1" >> >| >| 22. >> >| >| >> >| >>>onclick="window.document.caselist.displayed.value=window.document.caselis t >> . >> >| c >> >| >| aseselect.value"></p> >> >| >| 23. <p> >> >| >| 24. <textarea rows="6" name="displayed" cols="44"> >> >| >| 25. onclick text should bo here >> >| >| 26. </textarea></p> >> >| >| 27. >> >| >| 28. <%=newtext(test)%> >> >| >| 29. </form> >> >| >| >> >| >| >> >| >| >> >| > >> >| > >> >| >> >|
|
Sat, 15 Dec 2001 03:00:00 GMT |
|
|
Page 1 of 2
|
[ 25 post ] |
|
Go to page:
[1]
[2] |
|