Solved

Radio button postback not quite working ...

Posted on 2006-07-18
3
1,081 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now