Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 10th, 2005, 10:00 PM
jweizenblut jweizenblut is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Miami, Fl. US
Posts: 522 jweizenblut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 29 sec
Reputation Power: 2
Send a message via AIM to jweizenblut Send a message via Yahoo to jweizenblut
Reset SELECT...

I have a JavaScript function that resets a couple of items in my form. It currently resets an input and textarea.
I was wondering how do I make it reset a SELECT.
Current code as follows:

php Code:
Original - php Code
  1.  
  2. <script language="JavaScript">
  3. function rush_1200_check() {
  4. if(document.rush_1200.no_requests.checked)
  5. {
  6. document.rush_1200.number_of_prods.disabled=true;
  7. document.rush_1200.number_of_prods.value="";
  8. document.rush_1200.reason_for_request.disabled=tru  e;
  9. document.rush_1200.reason_for_request.value="";
  10. document.rush_1200.items.value = "CLICK HERE";
  11. }
  12. else
  13. {
  14. document.rush_1200.number_of_prods.disabled=false
  15. document.rush_1200.reason_for_request.disabled=fal  se;
  16. document.rush_1200.items.disabled=false;
  17. }
  18. }
  19. </script>


items is the SELECT I would like to have RESET to show SELECTEDINDEX number 1.

Any help would be greatly appreciated.

Reply With Quote
  #2  
Old May 11th, 2005, 09:03 AM
jcaughel jcaughel is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Buffalo, NY, USA
Posts: 283 jcaughel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 4 sec
Reputation Power: 2
Send a message via ICQ to jcaughel Send a message via AIM to jcaughel Send a message via Yahoo to jcaughel
RE: Reset SELECT...

I believe you can just set the value of the select field to the value you want... you'd have to use the value, though... what does the form look like?

instead of:
php Code:
Original - php Code
  1.  
  2. document.rush_1200.items.value = "CLICK HERE";


would
php Code:
Original - php Code
  1.  
  2. document.rush_1200.items.value = 1;

work?

-Jeff

Reply With Quote
  #3  
Old May 11th, 2005, 07:33 PM
jweizenblut jweizenblut is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Miami, Fl. US
Posts: 522 jweizenblut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 29 sec
Reputation Power: 2
Send a message via AIM to jweizenblut Send a message via Yahoo to jweizenblut
RE: Reset SELECT...

Sorry, no good. It simply goes empties the selected item. it doesn't go back to the first item.

Reply With Quote
  #4  
Old May 11th, 2005, 08:12 PM
jcaughel jcaughel is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Buffalo, NY, USA
Posts: 283 jcaughel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 4 sec
Reputation Power: 2
Send a message via ICQ to jcaughel Send a message via AIM to jcaughel Send a message via Yahoo to jcaughel
RE: Reset SELECT...

What does the form look like... for example, the following code will change the drop-down above from Client Side Things to Database Help... you need to ensure that you have the correct value...
Code:
javascript:document.forms[3].forum.value='sqlhelp';void(0);

if you are using IE, hit CTRL+O, paste that into the field and hit enter... it should change the value of the select.

I am pretty sure something similar works with Mozilla as well.

-Jeff

Reply With Quote
  #5  
Old May 11th, 2005, 09:48 PM
jweizenblut jweizenblut is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Miami, Fl. US
Posts: 522 jweizenblut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 29 sec
Reputation Power: 2
Send a message via AIM to jweizenblut Send a message via Yahoo to jweizenblut
RE: Reset SELECT...

The select for the form looks like this:

php Code:
Original - php Code
  1.  
  2. <select class="selectbox" name="items">
  3.   <option>CLICK HERE</option>
  4.   <option>N245620</option>
  5.   <option>N354569</option> 
  6.   <option>N555780</option>
  7.   <option>O890761</option>
  8.   <option>P874657</option>
  9.   <option>NOT LISTED</option>
  10. </select>


When the checkbox is selected, Code as follows:
php Code:
Original - php Code
  1.  
  2. <input name="no_requests" type="checkbox" onClick="rush_1200_check()" value="">


I need to reset the list from whatever option was selected to the first one, the one that currently says:
php Code:
Original - php Code
  1.  
  2. <option>CLICK HERE</option>


The code that does the reset is as follows:

php Code:
Original - php Code
  1.  
  2. <script language="JavaScript">
  3. function rush_1200_check() {
  4. if(document.rush_1200.no_requests.checked)
  5. {
  6. document.rush_1200.number_of_prods.disabled=true;
  7. document.rush_1200.number_of_prods.value="";
  8. document.rush_1200.reason_for_request.disabled=tru  e;
  9. document.rush_1200.reason_for_request.value="";
  10. document.rush_1200.items.value = "CLICK HERE";
  11. document.rush_1200.items.disabled =true;
  12. }
  13. else
  14. {
  15. document.rush_1200.number_of_prods.disabled=false
  16. document.rush_1200.reason_for_request.disabled=fal  se;
  17. document.rush_1200.items.disabled=false;
  18. }
  19. }
  20. </script>


To recap, I need the above function to disable the select and set it back to the default state, which has the first item listed shown.


Reply With Quote
  #6  
Old May 11th, 2005, 09:59 PM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 30 sec
Reputation Power: 2
RE: Reset SELECT...

I think this is what you're after?

Code:
onclick="document.rush_1200.items.selectedIndex=1;"


[edit]actually 0(zero) if you want the first item[/edit]

Reply With Quote
  #7  
Old May 12th, 2005, 12:29 AM
jcaughel jcaughel is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Buffalo, NY, USA
Posts: 283 jcaughel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 4 sec
Reputation Power: 2
Send a message via ICQ to jcaughel Send a message via AIM to jcaughel Send a message via Yahoo to jcaughel
RE: Reset SELECT...

None of your options have values associated with them. If you want the value to equal the displayed text, the form should look something like this:
Code:
<select class="selectbox" name="items">
  <option value='CLICK HERE'>CLICK HERE</option>
  <option value='N245620'>N245620</option>
  <option value='N354569'>N354569</option>  
  <option value='N555780'>N555780</option>
  <option value='O890761'>O890761</option>
  <option value='P874657'>P874657</option>
  <option value='NOT LISTED'>NOT LISTED</option>
</select>

Alternatively to have a number associated with each:
Code:
<select class="selectbox" name="items">
  <option value='0'>CLICK HERE</option>
  <option value='1'>N245620</option>
  <option value='2'>N354569</option>  
  <option value='3'>N555780</option>
  <option value='4'>O890761</option>
  <option value='5'>P874657</option>
  <option value='6'>NOT LISTED</option>
</select>


Then the suggestion...
Code:
onclick="document.rush_1200.items.value='CLICK HERE';"

or
Code:
onclick="document.rush_1200.items.value='0';"


(respectively) should work.


-Jeff

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Reset SELECT...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT