...

View Full Version : adding scripts to name="" and value="" fields



boeing747fp
06-26-2004, 02:40 PM
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?


<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>

neofibril
06-26-2004, 02:53 PM
I see no dropdowns or name fields in your example...

boeing747fp
06-26-2004, 03:51 PM
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

neofibril
06-26-2004, 04:00 PM
Are you not capable of producing a thoughtful description?

Willy Duitt
06-26-2004, 04:46 PM
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.


<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.

boeing747fp
06-26-2004, 05:43 PM
-------

boeing747fp
06-26-2004, 05:46 PM
NVM- I did something else with PHP... forget this convo

SpiritualStorms
06-29-2004, 02:55 PM
God i love sarcasm:


Are you not capable of producing a thoughtful description?

neofibril
06-29-2004, 03:14 PM
It is no fun offending people, however, so that would have been better left unsaid.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum