Jump to content

Multiple checkboxes to update the same field using java


Recommended Posts

Hi, I'm trying to set up a system to use 3 different checkboxes to each assign a value to a specific field from a details page. I could use a dropdown to achieve the effect I'm looking for but I'm new to javascript and databasing and am using this as a practice test to move on to bigger and better things. The code I'm using looks like this:

function confirmation()

{

if(document.getElementById(\"InsertRecordBIZ_appointments_Appointment_Confirmation\").checked)

{

document.getElementByID(\"InsertBIZ_appointments_Appointment_Status\").value=\"Confirmed\";

}

else if(document.getElementById(\"InsertRecordBIZ_appointments_Appointment_cancelReschedule\").checked)

{

document.getElementById(\"InsertRecordBIZ_appointments_Appointment_Status\").value=\"Reschedule\";

}

else if(document.getElementById(\"InsertRecordBIZ_appointments_Appointment_cancelEnd\").checked)

{

document.getElementById(\"InsertRecordBIZ_appointments_Appointment_Status\").value=\"End\";

}

else

{

document.getElementbyId(\"InsertRecordBIZ_appointments_Appointment_Status\").value=\"\";

}

}

document.getElementByID(\"3_appointments_action_confirmation\").onsubmit=confirmation;

any help on where I'm going wrong would be greatly appreciated.

-jsinger

Link to comment
Share on other sites

I'll try that thanks a ton!

EDIT: Well, I changed the references to EditRecord, unfortunately that didn't fix the solution. the script currently looks like this

function confirmation()

var confirm = document.getElementById(\"EditRecordBIZ_appointments_Appointment_Confirmation\").value;

{

if (confirm == yes)

{

document.getElementByID(\"EditRecordBIZ_appointments_Appointment_Status\").value=\"Confirmed\";

}

}

document.getElementByID(\"caspioform\").onsubmit=confirmation;

Link to comment
Share on other sites

  • 2 weeks later...

I think your syntax may be screwing it up. try:

<SCRIPT LANGUAGE="JavaScript"> 
function confirmation() 
var confirm = document.getElementById("EditRecordBIZ_appointments_Appointment_Confirmation").value;
{ 
if (confirm == "yes")
{ 
document.getElementByID("EditRecordBIZ_appointments_Appointment_Status").value="Confirmed"; 
} 
}
document.getElementByID("caspioform").onsubmit=confirmation;
</SCRIPT>

The backslash is used to escape quotes, so it was probably choking there. Also, by NOT having quotes around yes, javascript assumes that yes is a variable, which in your case it is not.

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...
 Share

×
×
  • Create New...