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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Please help a Novice!! - returning html form values without having to 'submit'

    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

  • #2
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,097
    Thanks
    15
    Thanked 1 Time in 1 Post
    this may be of help.
    Code:
    <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 -->

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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