FORUMS: list search recent posts

creating javascript vars..?

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Richard Williams
creating javascript vars..?
on Mar 6, 2010 at 12:17:13 am

Hi guys,
Could someone lend me a hand please? I have this created, Example where i have two images, onee adds a value of one to the input box on mouse down, and the other image subtracts 1 on mouse down.

What i want to do, is disable either the image, or the claculation when the value of the input box is equal to a set value. In other words, dont want to allow the box to go below 1, or above 10... Can anyone lend a hand please?

Thanks

Richard Williams
p.s. Please remember to rate our post replies and tick if solved. Also, please remember that we here are NOT employed by Adobe, we do this out of love and fun, so its always nice to recieve a Please and Thank You! :o)


Return to posts index

Richard Williams
Re: creating javascript vars..?
on Mar 6, 2010 at 2:00:41 am

or...

I could do it with two buttons, example2

What i want to do is say if value of text box is less than 1, swithc button 2 off, if value is higher than 10, switch button 1 off.

Richard Williams
p.s. Please remember to rate our post replies and tick if solved. Also, please remember that we here are NOT employed by Adobe, we do this out of love and fun, so its always nice to recieve a Please and Thank You! :o)


Return to posts index

Richard Williams
Re: creating javascript vars..?
on Mar 6, 2010 at 5:06:59 am

ok, Ive managed to do it, more by luck than judgement, i found a bit of javascript online and fiddled with it until it worked... Would still welcome any insight though... Ill demonstrate what i did here...


in the head tag i put this...

<script type="text/javascript">

function Disab() {

frm=document.form1

if(frm.adult_number_tickets.value==10)

{frm.button_1.disabled=true}

else {frm.button_1.disabled=false}

if(frm.adult_number_tickets.value==1)

{frm.button_2.disabled=true}

else {frm.button_2.disabled=false}

}

</script>


On my button_1, i put this

<input name="button_1" type="button" class="adult_number_ticketsCopy" id="button_1" onMouseDown="KW_calcForm('adult_number_tickets',1,-1,'#adult_number_tickets','+','1')" value="" onClick=Disab(); />


I think onClick=Disab(); just submits the value on the click event...?


and button_2 i put this

<input name="button_2" type="button" class="adult_number_ticketsCopy2" id="button_2" onMouseDown="KW_calcForm('adult_number_tickets',1,-1,'#adult_number_tickets','-','1')" value="" onClick=Disab(); disabled="true" />


I start the button as disabled because there is an initial value of 1 in the text box, without settign it as disabled from the start, it allowed me to go below 1 if i clicked the down button first.


and of course, an input field


<input name="adult_number_tickets" type="text" class="adult_number_tickets" id="adult_number_tickets" value="1" readonly="readonly" />

Richard Williams
p.s. Please remember to rate our post replies and tick if solved. Also, please remember that we here are NOT employed by Adobe, we do this out of love and fun, so its always nice to recieve a Please and Thank You! :o)



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]