SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2010
    Location
    Atlanta, Ga
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Handling Querystrings with Javascript

    Hi,

    This post involves an issue I'm experiencing with handling querystring values after a radio button has been checked.

    I can capture and parse a multi-parameter querystring and place those values into form fields upon arriving at a certain simple HTML/Javascript only web page, no problem.

    It's when a certain radio button is clicked after the page has loaded that I need to place another querystring parameter's value into a form field.

    I've attempted to replace a form field's value by using an onclick event in the said radio button. The javascript function being called is in an external js file (linked in the head element of the html page) and is seen below:

    Code:
    function setINDBOTTUID() {
    var textListKOID = document.qdbform.elements('_fid_302');
    var textListUID = document.qdbform.elements('_fid_17');
    var textListEmail = document.qdbform.elements('_fid_16');
    var radListINDBOTT = document.getElementsByName('_fid_23');
    if (textListUID=="") { 
    	if ((textListKOID.value=="") && (radListINDBOTT[2].checked==true)) {
    		textListUID.value = textListEmail;
    }}}
    In the radio button element, I have the following onclick event code:

    Code:
    onClick="setINDBOTTUID();"
    What I'm expecting to ultimately happen when all conditions are true: When the radio button is clicked, I want the value in textListEmail to be copied to textListUID and the form field _fid_17 will contain what is in textListUID.

    I would expect the see the form field _fid_17 abruptly populate with this value, but it is not doing so.

    I may have a misunderstanding of how this should all take place, but I do successfully write null values to form fields in the same manner.

    Any help is appreciated,
    Chris

  2. #2
    SitePoint Member
    Join Date
    Apr 2010
    Location
    Atlanta, Ga
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The snippet of code for the called function should have been written as you see it below.

    Code JavaScript:
    function setINDBOTTUID() {
    var textListKOID = document.qdbform.elements('_fid_302');
    var textListUID = document.qdbform.elements('_fid_17');
    var textListEmail = document.qdbform.elements('_fid_16');
    if (textListKOID.value!="") { 
    	if(textListUID.value=="") textListUID.value= textListEmail.value;
    	}
    }

    The mistake I made was in checking the condition of a radio button field:

    Code JavaScript:
    if ((textListKOID.value=="") && (radListINDBOTT[2].checked==true))

    Since the fuction is called only when radListINDBOTT[2] was clicked, it made no sense to check for it. That, and the syntax was wrong anyway.


Tags for this Thread

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
  •