Wrox Programmer Forums
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2005, 05:11 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

i wnat to go to <select name="book_date" id="book_date" onChange="location.href='display_bookings.asp'">


 
Old January 27th, 2005, 05:14 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

the fix:

onChange="form.submit()"

 
Old January 27th, 2005, 08:57 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

as it sits:

<select name="book_date" id="book_date" onChange="form.submit()">
<option value="<%=date()%>">Today</option>
<option value="<%=date()-1%>">1 day ago</option>
<option value="<%=date()-2%>">2 days ago</option>
<option value="<%=date()-3%>">3 days ago</option>
<option value="<%=date()-4%>">4 days ago</option>
<option value="<%=date()-5%>">5 days ago</option>
</select>

however, when i try to select 'Today' it doesnt go to the next page. only 'onChange' of the other values, 1 day ago, 2 days ago etc......

any ideas?

 
Old January 27th, 2005, 10:36 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well in that case you need a default value so that you always fire the onchange:
Code:
<select name="book_date" id="book_date" onChange="form.submit()">
<option value="">Choose a date</option>
<option value="<%=date()%>">Today</option>
<option value="<%=date()-1%>">1 day ago</option>
<option value="<%=date()-2%>">2 days ago</option>
<option value="<%=date()-3%>">3 days ago</option>
<option value="<%=date()-4%>">4 days ago</option>
<option value="<%=date()-5%>">5 days ago</option>
</select>
You will then have to have an onsubmit handler on the form to check that the selectedIndex of the list is greater than 0.

Personally I think this is poor UI design, it's all too easy to choose the wrong option from a selectbox but now the form submits automatically. Better to make them pick a date and click a submit button when they can see they chose correctly.

--

Joe (Microsoft MVP - XML)
 
Old January 27th, 2005, 11:27 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

i changed it to:

<select name="book_date" id="book_date" onChange="form.submit()">
<option selected="selected">Please Select</option>
<option value="<%=date()%>">Today</option>
<option value="<%=date()-1%>">1 Day ago</option>
<option value="<%=date()-2%>">2 Days ago</option>
<option value="<%=date()-3%>">3 Days ago</option>
<option value="<%=date()-4%>">4 Days ago</option>
<option value="<%=date()-5%>">5 Days ago</option>
<option value="<%=date()-1%>">6 Days ago</option>
<option value="<%=date()-2%>">7 Days ago</option>
<option value="<%=date()-14%>">2 Weeks ago</option>
<option value="<%=date()-21%>">3 Weeks ago</option>
<option value="<%=date()-31%>">1 Month ago</option>
<option value="<%=date()-62%>">2 Months ago</option>
<option value="<%=date()-93%>">3 Months ago</option>
<option value="<%=date()-124%>">4 Months ago</option>
<option value="<%=date()-155%>">5 Months ago</option>
<option value="<%=date()-186%>">6 Months ago</option>
</select>










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.