/    Sign up×
Community /Pin to ProfileBookmark

Change Value of Select Box

I have a simple html form with 3 fields. First field is “Select date range”, in which I have a number of options including “Enter Date Range…”. After this field I have “From” and “To” fields in which the user can manually enter dates. I want to be able to change the value of the “Select date range” field to “Enter Date Range…” when the user enters a value in the “From” or “To” fields. This is a simplified version of the form code:

[CODE]
Select date range:
<select name=”daterange”>
<option>All dates</option>
<option>Past 1 month</option>
<option>Past 3 months</option>
<option>Past 6 months</option>
<option>Past year</option>
<option>Enter date range…</option>
</select>

From (DD-MM-YYYY):
<input type=”Text” name=”input1″ value=””>

To (DD-MM-YYYY):
<input type=”Text” name=”input2″ value=””>
[/CODE]

Thanks very much in advance. Any help greatly appreciated.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorJan 12.2006 — 
want to be able to change the value of the "Select date range" field to "Enter Date Range..."
[/quote]

?

- "Select date range" is not a field, it is a string written on page... Can you clear your demand?
Copy linkTweet thisAlerts:
@notsaswmotauthorJan 12.2006 — "Select date range" is the label of the field. I want to be able to change the value of the field to "Enter Date Range..."
Copy linkTweet thisAlerts:
@SelrachJan 12.2006 — Change the other two input fields to the following:
[CODE]
From (DD-MM-YYYY):
<input type="Text" name="input1" value="" onChange="document.getElementByName('daterange').options[5].selected=true;">

To (DD-MM-YYYY):
<input type="Text" name="input2" value="" onChange="document.getElementByName('daterange').options[5].selected=true;">
[/CODE]
×

Success!

Help @notsaswmot spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...