Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post

    adding scripts to name="" and value="" fields

    i have some dropdowns with that javascript with the "Next Sunday" thing and i need the name field to have that script in it.... but i tried pasting the script inside the name="" quotes and the name field stays as the script itself........ and way i can get the name="" field to show the result of the script?

    Code:
    <script>
    Date.prototype.getNextSunday = function() {
    	var nextSunday = this;
    	switch(nextSunday.getDay()) {
    		case 0:	return nextSunday; //it's Sunday!
    		default:	nextSunday.setDate(nextSunday.getDate() + (7 - nextSunday.getDay()));
    				return nextSunday;
    	}
    	return false;
    }
    var today = new Date();
    var sun = today.getNextSunday();
    document.write(sun.getMonth()+1 + "-" + sun.getDate() + "-" + sun.getFullYear());
    </script>

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I see no dropdowns or name fields in your example...

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    that's not an example... that is the code i want to be performed to create the name="" field in the <select name="HERE"> thing

  • #4
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Oh, that makes perfect sense.

    Are you not capable of producing a thoughtful description?

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There are many ways of doing this. Below is an example of using the forms collection but you could also go in thru the DOM. It would all depend upon how your page is constructed.

    Code:
    <form>
    <select name="test" onclick="alert(this.name)">
    </form>
    
    
    <script>
    Date.prototype.getNextSunday = function() {
    	var nextSunday = this;
    	switch(nextSunday.getDay()) {
    		case 0:	return nextSunday; //it's Sunday!
    		default:	nextSunday.setDate(nextSunday.getDate() + (7 - nextSunday.getDay()));
    				return nextSunday;
    	}
    	return false;
    }
    var today = new Date();
    var sun = today.getNextSunday();
    document.forms[0].elements[0].name=(sun.getMonth()+1 + "-" + sun.getDate() + "-" + sun.getFullYear());
    </script>
    But as neofibril pointed out.
    If you are looking for a specific solution you will need to learn to be more specific.

  • #6
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    -------
    Last edited by boeing747fp; 06-26-2004 at 06:48 PM.

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    NVM- I did something else with PHP... forget this convo

  • #8
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ahahahahahahahahahahahahahahaha.........

    God i love sarcasm:

    Code:
    Are you not capable of producing a thoughtful description?
    LovesWar

  • #9
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Actually, the sarcasm was in the title...

    It is no fun offending people, however, so that would have been better left unsaid.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •