Solved

Radio button postback not quite working ...

Posted on 2006-07-18
3
1,086 Views
Last Modified: 2012-06-22
Hi all

I have a radio button group that gives two options: yes and no, and I want to make my form postback when these are clicked ... (as I am using php to create dynamic forms based on user input)

I found out how (or so i thought) using this method:

                        <input onfocus="this.form.action='screen_3.php';this.form.submit()" type="radio" name="lbnw" id="lbnw_no" value="no" />
                        <label for="lbnw_no">No</label>      
                        <br />                        
                        <input onfocus="this.form.action='screen_3.php';this.form.submit()" type="radio" name="lbnw" id="lbnw_yes" value="yes" />
                        <label for="lbnw_yes">Yes</label>

But while that causes a postback just like a form submission should, in Forefix it doesn't seem to remember the value of the radiobutton I just selected to cause the postback.

Eg. say the radio button is set to 'no' by default ...then I click 'yes' which causes the form to submit ...the value that is posted on the form submission is still 'no' in Firefox (works in IE though).

Does anyone know a way around this BESIDES me posting every variable in the query string like this:

                        <input onfocus="location.href='screen_3.php?var1=blah&var2=blah';" type="radio" name="ccpi" id="ccpi_no" value="no" />
                        <label for="ccpi_no">No</label>      
                        <br />                        
                        <input onfocus="location.href='screen_3.php?var1=blah&var2=blah';" type="radio" name="ccpi" id="ccpi_yes" value="yes" />
                        <label for="ccpi_yes">Yes</label>

Cheers,
Mark
                        
0
Comment
Question by:msiedle
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
DireOrbAnt earned 500 total points
ID: 17135717
Try onclick vs onfocus:                    
                    <input onclick="this.form.action='screen_3.php';this.form.submit()" type="radio" name="lbnw" id="lbnw_no" value="no" />
                    <label for="lbnw_no">No</label>    
                    <br />                    
                    <input onclick="this.form.action='screen_3.php';this.form.submit()" type="radio" name="lbnw" id="lbnw_yes" value="yes" />
                    <label for="lbnw_yes">Yes</label>
0
 
LVL 2

Author Comment

by:msiedle
ID: 17135729
Ahhhh, I'd have never figured that out. Didn't think it made any difference. Thank you!

M
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17135768
I see a lot of people doing onfocus, but that's too early in the event game :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses how to create an extensible mechanism for linked drop downs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: blockā€¦
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question