PDA

View Full Version : a little help with my code please!


startbar
03-26-2006, 04:09 PM
<form action="https://secure.nochex.com" method=post name=quickpay onsubmit="return submitForm();">

<title>XXXXXXXX</title>
<div style="padding-top:10px;padding-bottom:5px;padding-left:2px;padding-right:2px;">


<script type="text/javascript">
function changetext(whichcontent){
if (document.all||document.getElementById){
cross_el=document.getElementById? document.getElementById("descriptions"):document.all.descriptions
cross_el.innerHTML=whichcontent
}
else if (document.layers){
document.d1.document.d2.document.write(whichcontent)
document.d1.document.d2.document.close()
}
}
function update(){
var f1 = document.quickpay;
var amt = 0
if (f1.plug.checked){
amt += 58.75;

changetext("Total £: <input type='text' name='amount' style='background-color: #FFFFFF; font-family: verdana; font-size: 8pt; color: #990000; font-weight: none; border: 1px solid #FFFFFF;'>");
}else{
changetext("Total £: <input type='text' name='amount' style='background-color: #FFFFFF; font-family: verdana; font-size: 8pt; color: #990000; font-weight: none; border: 1px solid #FFFFFF;'>");
}
f1.amount.value=amt;
}
</script>
</head>

<body bgcolor="#990000" onload="changetext('<b>Total £: <input type='text' name='amount' id='amount' style='background-color: #FFFFFF; font-family: verdana; font-size: 8pt; color: #990000; font-weight: none; border: 1px solid #FFFFFF;'></b>')">

<input name="email" size="35" type="hidden" value="xxx" style="background-color: #FFFFFF; font-family: verdana; font-size: 8pt; color: #990000; font-weight: none; border: 1px solid #FFFFFF;"><img src="/makeapayment.jpg" border="0"><br>I would like to pay for a Plug Point - £50 + vat <input type="checkbox" name="plug" onclick="update()"><br>
<br>

My stand number is: <input type="text" size="10" id="description" name="description" style="background-color: #FFFFFF; font-family: verdana; font-size: 8pt; color: #990000; font-weight: none; border: 1px solid #CCCCCC;"><br><br>

<ilayer id="d1" width="35" height="15" visibility="hide">
<layer id="d3" width="35" height="15">
<div id="descriptions" align="left">


</div>
</layer>
</ilayer>
<br>
<input name="cancelurl" type="hidden" value="">
<input type="submit" value="Continue to Payment" style="background-color: #FFFFFF; font-family: verdana; font-size: 8pt; color: #990000; font-weight: none; border: 1px solid #990000;" name=submit1>
</form>

Can someone please add some code to this for me! I would really appriciate it. Need the tickbox <input type="checkbox" name="plug" onclick="update()"> and the stand text field <input type="text" size="10" id="description" name="description" style="background-color: #FFFFFF; font-family: verdana; font-size: 8pt; color: #990000; font-weight: none; border: 1px solid #CCCCCC;"> to be required fields. Maybe if possible could you do it so that the submit button is disabled until the box is ticked and the field typed into.

Many thanks in advance

startbar
03-27-2006, 01:47 PM
bump - come on someone! please!

Kor
03-27-2006, 03:17 PM
let's try to simplify things. You wanna validate for required fields? How? You want them to be filled nomatter, or is a certain way (you need for sure another code, yours is deprecated, so that we might find a new brad one for you, if we know the conditions)
------
do you really need layer/ylayer tags? Looks like an old NS4 code to me...

startbar
03-28-2006, 11:41 AM
yes the checkbox MUST be ticked in order to submit and the text field MUST be entered into. That is the only condition.

But the form path (to nochex website) etc must remain intact.

Help appriciated, thanks

Kor
03-28-2006, 03:18 PM
ca u detail a little bit more, please? Or gimme a PM.

Kor
04-03-2006, 09:26 AM
Move the form tag below the body. Now add this function


function validate(f){
if(!f['plug'].checked){
alert('The ckeckbox plug is required');
return false
}
if(f['description'].value.length<1){
alert('The field description is required')
return false
}
}


and use this function on submit

<form action="https://secure.nochex.com" method=post name=quickpay onsubmit="return validate(this);">

startbar
04-03-2006, 09:57 AM
WORKS!

thank you so much dude