51 users online (0 members and 51 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 3
  2. Form Results Processing    Forum: Website Scripts Forum
    Replies: 2
  3. Processing HTML events in Javascript - problem    Forum: Javascript Forum
    Replies: 1
  4. Replies: 1
  1. #1
    woodknut's Avatar
    Disabled

    Status
    Offline
    Join Date
    Dec 2003
    Posts
    32

    Help setting button values before processing

    I have written a survey page within an HTML FORM that I want to submit to an ASP page to write the form data to a text file.

    The good news is that the ASP page writes data to a text file.

    The bad news is that I'm not getting it all. Or more specifically I need to deal with "undefined" data.

    HTML code snippet (there are actually 30 radio groups) :
    <form action="survey.asp" method="post" onSubmit="return checkCharter()">
    ...
    1<input type="RADIO" name="btn1" value="1" checked>&nbsp;
    2<input type="RADIO" name="btn1" value="2" checked>&nbsp;
    3<input type="RADIO" name="btn1" value="3" checked>&nbsp;
    4<input type="RADIO" name="btn1" value="4" checked>&nbsp;
    5<input type="RADIO" name="btn1" value="5" checked>&nbsp;
    6<input type="RADIO" name="btn1" value="6" checked>
    ...
    1<input type="RADIO" name="btn2" value="1" checked>&nbsp;
    2<input type="RADIO" name="btn2" value="2" checked>&nbsp;
    3<input type="RADIO" name="btn2" value="3" checked>&nbsp;
    4<input type="RADIO" name="btn2" value="4" checked>&nbsp;
    5<input type="RADIO" name="btn2" value="5" checked>&nbsp;
    6<input type="RADIO" name="btn2" value="6" checked>
    ...
    <input type="checkbox" name="charter" value="charter" checked>&nbsp;
    <b>YES</b>, keep me in mind with a discount as a charter member.<br><br>
    ...
    </form>

    If the user unchecks the "charter" checkbox, the value becomes NULL or undefined...and therefore is not written by the ASP script.

    So why can't I change the value using javascript :

    function checkCharter() {
    var element;
    element = document.getElementById('charter');
    if( !element.checked )
    element.value = "nocharter";
    }


    Javascript is client side, yes? So any changes to the form elements occur there prior to being sent to ASP. So what difference should it make if "I" do it via javascript, or the user does so by "action"?

    BTW I've tried returning TRUE from the function to no avail.

    Any help is greatly appreciated.
    W.

  2. #2
    fawh's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2004
    Posts
    8
    I'm not sure what you are tring to do. But, if you want to prevent users from unchecking

    <input type="checkbox" name="charter" value="charter" checked>

    in all cases, you could make it hidden

    <input type="hidden" name="charter" value="charter" checked>

  3. #3
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    If you need a definitive 'Yes or No' then use a pair of radio buttons instead. one for yes, one for no?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread