SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Mar 2002
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to read value of non text field after submission?

    I have a form that, during submission to another page, uses the submitted text field data and creates a cookie. But how would I do that with a radio button/checkbox field or pulldown? Just fyi, the code is created using onsubmit() and processes this before the response page.

    All demos I see are for self submitting (same page) scripts. Not for those going from form.php to response.php and I cannot use this type of submission and find a value for a NON text field. I need to recognize non text fields since I want to create cookies for all form fields, not just text fields.

    The code I have, to read the value of a text field is here:
    var email = document.myform.email.value.split(' ')[0];

    I just want to have something similar to above, using 'myform' as the form name, but able to get the value for any *non text field*

    is this possible? The rest of the code I won't post as it isn't relevant. I just need to read a value of a non text field and I can work with that.

    Thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Guru
    Join Date
    Mar 2002
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am asking a javascript question, based on onsubmit. Does anybody know how to read a value of a non text field so I can store the value for a cookie? Is that that complicated? If so, I will scratch this idea for my script.

    I figured somebody would know.

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Guru
    Join Date
    Mar 2002
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, I need to *get the value* and set a javascript cookie to that.

    Thanks, though. Does anybody know how to do this for checkbox/radio/pulldowns? All I need is to set the var for it, that's it. Just a variation of the line of code I put up. I can do the rest.

  6. #6
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you are looking for?

    document.myForm.myRadio[0].value;
    document.myForm.myCheckbox[0].value;
    document.myForm.myCheckbox.value;

  7. #7
    SitePoint Guru
    Join Date
    Mar 2002
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On edit, I couldn't get it to work before. I saw a syntax error on my end. Now I see the cookie IS saved. But when I trie to display it, I get undefined so I just need to learn how to display that value on the response page. All I get now is 'undefined' using a basic php call.

    Thank you

  8. #8
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am getting pulldown values via this code:

    var val=form.country.options[form.country.options.selectedIndex].value;
    self.location='Search.php?country=' + val;

    It just grabs the dropdown box parameter and then adds it to a url. Does this help at all? It took me 2 days to get this parameter setup right


Bookmarks

Posting Permissions

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