...

View Full Version : Please help a Novice!! - returning html form values without having to 'submit'



mattclayb
07-07-2005, 09:26 AM
Hi,

I know some PHP and SQL, but think that I require Javascript as the solution to my problem, but I am a complete novice in JS.

THE TASK

I want to create two dropdown select menus in HTML on the same page, and have Javascript update whatever is selected, so I can return the values without the need of a submit button and without leaving the page. This is so I can grab the form values as variables in PHP and create a MySql query from them.

I would very much appreciate any ideas!

regards,

Matt

crmpicco
07-07-2005, 10:22 AM
this may be of help.


<select name="date<%=k%>"
onChange="document.form.birthday<%=k%>.value=document.form.date<%=k%>.options[document.form.date<%=k%>.selectedIndex].value+document.form.month<%=k%>.options[document.form.month<%=k%>.selectedIndex].value+document.form.year<%=k%>.options[document.form.year<%=k%>.selectedIndex].value;"
style="color: black; font: 7pt Verdana, Arial, Helvetica, sans-serif;">
<!-- document.form.birthday<%=k%>.value=document.form.birthday<%=k%>.value+document.form.date<%=k%>.options[document.form.date<%=k%>.selectedIndex].value -->
<!--document.form.chdbirthday<%=j%>.value=document.form.chddate<%=j%>.options[document.form.chddate<%=j%>.selectedIndex].value+document.form.chdmonth<%=j%>.options[document.form.chdmonth<%=j%>.selectedIndex].value+document.form.chdyear<%=j%>.options[document.form.chdyear<%=j%>.selectedIndex].value-->

<%
Response.write "<option> --- </option>"
For d = 01 to 31
if len(d) = 1 then
Response.Write "<option value=0"& d & ">" & d & "</option>"
else
Response.write "<option value=" & d & ">" & d & "</option>"
end if
Next
%>
</select>
<select name="month<%=k%>"
onChange="document.form.birthday<%=k%>.value=document.form.date<%=k%>.options[document.form.date<%=k%>.selectedIndex].value+document.form.month<%=k%>.options[document.form.month<%=k%>.selectedIndex].value+document.form.year<%=k%>.options[document.form.year<%=k%>.selectedIndex].value;"
style="color: black; font: 7pt Verdana, Arial, Helvetica, sans-serif;">


<%
Response.write "<option> --- </option>"
For m = 01 to 12
if len(m) = 1 then
response.Write "<option value=0" & m & ">" & MMtoMMM(m) & "</option>"
else
response.Write "<option value=" & m & ">" & MMtoMMM(m) & "</option>"
end if
Next
%>
</select>
<%
Dim three_years_ago
three_years_ago = year(date) - 3
%>
<select name="year<%=k%>"
onChange="document.form.birthday<%=k%>.value=document.form.date<%=k%>.options[document.form.date<%=k%>.selectedIndex].value+document.form.month<%=k%>.options[document.form.month<%=k%>.selectedIndex].value+document.form.year<%=k%>.options[document.form.year<%=k%>.selectedIndex].value;"
style="color: black; font: 7pt Verdana, Arial, Helvetica, sans-serif;">
<%
Response.write "<option> --- </option>"
For y = three_years_ago to year(date)
Response.Write "<option value=" & y & ">" & y & "</option>"
Next
%>
</select>
<!-- TEMPORARY TEXT FIELD FOR INFANT BIRTHDAY CHECKER -->
<input type="hidden" name="birthday<%=k%>" size="5" style="font:7pt;" value="" maxLength="10">
<!-- TEMPORARY TEXT FIELD FOR INFANT BIRTHDAY CHECKER -->

glenngv
07-07-2005, 10:40 AM
http://www.ashleyit.com/rs/jsrs/select/php/select.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum