|
From: Hagster on 17 Jul 2006 07:49 Hello All, I have 2 radio buttons one when ticked has the value 'OK' and the other 'NOT OK' in the same form I had a selection drop down that allows the user to select 'YES' on selecting yes an on change pop up message set up as a behaviour pos up and say 'by selecting yes you agree to blah blah and you selected XXXXXX' How can i get the pop up messed to display 'OK' or 'NOT OK' depending which radio button is ticked this i sbefore submitting the form. Or as you tick one of the radio buttons it sets a variable, then i can just display that variable in the pop up message. Any pointers please My knowledge of the scripting for onchange things etc is limited. Regards Guy
From: Dan Bracuk on 17 Jul 2006 09:07 My pointer is to improve your knowlege of scripting. I learned javascript by buying the book, Teach Yourself Javascript in 24 Hours. It's a good book.
From: Hagster on 17 Jul 2006 10:36 Hello Dan, I appriciate your pointer, and i do read alot on the net before I post here, I alsp appriciat you probley get anoyed at people that just use this place for a quick answer with putting no real effort in. But I can asure you that I have spent most of my working day trying to figure this one out before I posted to this forum. The script below sort of solves a few things <script language="JavaScript"> <!-- Hide function test1(form) { if (form.text1.checked) alert("Please enter a string!") else { alert(""+form.text1.value+""); } } // --> </script> <form name="first"> <input name="text1" type="checkbox" value="yesyes" /> <select name="gogogo" onchange="test1(this.form)"> <option value="none">none</option> <option value="some">some</option> </select> </form> but doing it that way I cant get <CFOUTPUT> variables to apear in the msg, if i try to change the value of the tickbox like <input name="text1" type="checkbox" onClick="if{this.checked}{this.form.text1.value='IAMTICKED'}" > allows me to onchange another form element and it pops up a msg with the text1 value in 'IAMTICKED' but I cant seem to get all the bits working together. two checkboxes or two radial spots one with value 'OK' one with 'NOTOK' and on the change of a drop down list it would show me the value of which ever check/radial is selected. Now if I do it with javascript in the header i cant get the cfoutput variables to return in the message and if i do it ini the form after the elements i cant get the form element value to return I need both you see and after 4 hours messing about i thought Id ask :) below is complete code to date for this. <script type="text/JavaScript"> <!-- function MM_popupMsg(msg) { alert(msg); } //--> </script> ******************* <input name="review" type="radio" value="ok" /> <input name="review" type="radio" value="notok" /> <select name="select" onchange="MM_popupMsg('<cfoutput>#query.name# by selecting \'YES\' you agree that:\r Review = XXXXXX</CFOUTPUT>')"> <option value=" " selected="selected"></option> <option value="YES">YES</option> </select> the XXXXX is where i need my radio button value to go. Kind Regards Guy
From: stitchy on 18 Jul 2006 07:09 Hi, A good reference site for Javascript is www.irt.org. You'll actually need to loop through the radio button field to see if anything has been selected. <form name="form"> <script type="text/JavaScript"> <!-- function MM_popupMsg(msg,formfield) { var msg2 = ''; for (var i=0;i<formfield.length;i++) { if (formfield[i].checked) { msg = formfield[i].value; } } alert(msg + msg2); } //--> </script> ******************* <input name="review" type="radio" value="ok" /> <input name="review" type="radio" value="notok" /> <select name="select" onchange="MM_popupMsg('sdfdsfds by selecting \'YES\' you agree that:\r Review = ',document.form.review)"> <option value=" " selected="selected"></option> <option value="YES">YES</option> </select> </form>
From: drforbin1970 on 18 Jul 2006 11:05 You appear to just need a little help, here's the answer. It's basically hardcoded as opposed to looping thru objects but it gets the job done. You can also modify to make sure the OK button is selected before it can be submitted. <script> function okiedokie(){ <!-- stop processing if first dropdown value(blank) is selected --> if(window.document.agreement.yesno.selectedIndex == 0){ return false; } if(window.document.agreement.oknot[0].checked==false && window.document.agreement.oknot[1].checked==false ){ alert('You must select either OK or NOT OK') <!-- reset dropdown box --> window.document.agreement.yesno.selectedIndex = 0; return false; } if(window.document.agreement.oknot[0].checked==true){ alert('You selected OK'); window.document.agreement.yesno.selectedIndex = 0; return false; } if(window.document.agreement.oknot[1].checked==true){ alert('You selected NOT OK'); window.document.agreement.yesno.selectedIndex = 0; return false; } } </script> <form name="agreement"> <input type="radio" name="oknot" value="ok">ok <input type="radio" name="oknot" value="not ok">not ok <select name="yesno" onchange="okiedokie(this)"> <option value="">Select Yes or No <option value="Yes">Yes <option value="No">No </select> </form>
|
Next
|
Last
Pages: 1 2 Prev: Verity issue after purging a collection Next: Reading HTTP Header Variables |