Jump to content

Select a value from drop-down menu or enter text?


Recommended Posts

I need to create the option on my form to allow a user to select a value for club name from a dropdown list of values, or if that value isn't present in the list I'd like them to be able to manually enter the club name in a text field? The link to the datapage is below:

http://b2.caspio.com/dp.asp?AppKey=405e ... 27481bb307

frederickw/Obiwan3!

The home club defaults to the team that is logged in, and that's what I want but we also need to be able to override this with a text entry. I know it can be done with JavaScript and a little validation, I just don't know enough JS to do it. Any help would be much appreciated.

And here's my hacked psuedo code, just to give an idea of how I need it to validate:

if matches_team_b == " "

and Virtual6 == " "

alert "Please select visiting club from drop-down menu or type in club name."

//Think I only need to validate on visitor as we are defaulting value of home club to club that is logged in to create the record, in all likelyhoods that's what this will be.

else

if Virtual6 != " "

function {

document.getElementById('cbParamVirtual6').value;

('InsertRecordmatches_team_b');

}

Link to comment
Share on other sites

Hello,

You can have a checkbox right next to your dropdown and ask the user check the box if the value they want does not exist in the dropdown. Once they check this checkbox the textbox will be enabled to enter the value there. Then get this value to the actual field. You can place the code in the Footer of the page:

function d_text()

{

document.getElementById("cbParamVirtual6").disabled = true;

}

function f_boxcheck()

{

if(document.getElementById("CHECKBOXID").checked){

document.getElementById("cbParamVirtual6").disabled = false;

}else {document.getElementById("cbParamVirtual6").disabled = true;}

}

function transfer()

{

document.getElementById("InsertRecordmatches_team_a")[0].value = document.getElementById("cbParamVirtual6").value;

}

window.onload = d_text;

document.getElementById("CHECKBOXID").onclick = f_boxcheck;

document.getElementById("caspioform").onsubmit = transfer;

In the URL you provided "cbParamVirtual6" is the ID of the textbox you want to disable or enable conditionally and "InsertRecordmatches_team_a" is the ID if the dropdown. Please replace "CHECKBOXID" with the real ID of the checkbox.

Hope that helps.

Regards,

NKamalan

Link to comment
Share on other sites

This is awesome. It worked like a charm, one last question - my form is basically for clubs/teams to enter matches. The way it's setup now, I have RLS defaulting the first team pulldown menu to the team that's logged on, but there are instances when we'll need to override that one as well (say for instance, another team is hosting 2 out-of-town teams on thier field, they would be responsible for the referee allocation) Is there a way to do this for both sides - creating an alternate-entry via checkbox selection? Any information you can provide on this would be most helpful, you've already helped a ton! Thanks in advance...

K.

Link to comment
Share on other sites

Hello There,

Try this for two dropdowns:

function d_text()

{

document.getElementById("FirstTexboxID").disabled = true;

document.getElementById("SecondTexboxID").disabled = true;

}

function f_boxcheck()

{

if(document.getElementById("FIRSTCHECKBOXID").checked){

document.getElementById("FirstTexboxID").disabled = false;

}else {document.getElementById("FirstTexboxID").disabled = true;}

}

function s_boxcheck()

{

if(document.getElementById("SECONDCHECKBOXID").checked){

document.getElementById("SecondTexboxID").disabled = false;

}else {document.getElementById("SecondTexboxID").disabled = true;}

}

function transfer()

{

if (document.getElementById("FIRSTCHECKBOXID").checked)

{

document.getElementById("FirstDropdown")[0].value = document.getElementById("FirstTexboxID").value;

}

if (document.getElementById("SECONDCHECKBOXID").checked)

{

document.getElementById("SecondDropdown")[0].value = document.getElementById("SecondTexboxID").value;

}

}

window.onload = d_text;

document.getElementById("FIRSTCHECKBOXID").onclick = f_boxcheck;

document.getElementById("SECONDCHECKBOXID").onclick = S_boxcheck;

document.getElementById("caspioform").onsubmit = transfer;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...