Page 1 of 1

disable text field..not with "disabled" tag btw

Posted: Wed Sep 24, 2003 3:25 pm
by qads
elo
got a weird problem, i have 2 text fields that i don't want the user to use, i tried useing:

Code: Select all

<input name="coupon_valid_from" type="text" size="10" disabled>
if i use this method, then its not set in php, so i can't see what was in it (i use another script to put value in it).

is there anything else i can use for this? something that will stop the user from typeing in this field, but it should be set in php...

thanks alot

Posted: Wed Sep 24, 2003 3:40 pm
by Leviathan
So basically you want hidden fields so you can pass a value to the server without the user knowing? I can't remember the exact syntax, but you either use

Code: Select all

<input type="hidden"...> or <input type="text" hidden...>
. I think it's the first choice.

Posted: Wed Sep 24, 2003 3:52 pm
by qads
well, not exectly, i still need to show what is in the text box, i am playing around with hidden fields now, hopefully i will get it working...if so, i will post it...

any idea on how to call a function 2 times "onclick"?

Code: Select all

<a href="#" onClick="getCalendarFor(document.coupon.coupon_valid_from);getCalendarFor(document.coupon.coupon_valid_from_show);return false;">Choose Date</a>
this is not working :?

thanks

Posted: Wed Sep 24, 2003 4:10 pm
by volka
try

Code: Select all

<html><body>
	<form method="post" action=".">
		<input type="text" name="test1" value="value 1" readonly="readonly" />
		<textarea name="test2" readonly="readonly" >value 2.a
		value 2.b</textarea>
	</form>
</body></html>
see also: http://www.w3.org/TR/html4/interact/forms.html#adef-readonly

Posted: Wed Sep 24, 2003 4:23 pm
by microthick
For normal INPUT fields you can use the JavaScript blur() function, if that helps.

Code: Select all

<input type="text" size="40" onClick="blur();">
This will disallow the user to edit any text in the input box.

Posted: Wed Sep 24, 2003 4:32 pm
by Leviathan
To call a function twice, you could make a second function that does the two calls for you, and call that new function.

Code: Select all

a &#123;
    b(1);
    b(2);
&#125;


<input type="text" name="somefield" onclick="a();">

Posted: Wed Sep 24, 2003 6:25 pm
by qads
cool, readonly works nicely :D


thanks guys :)

Posted: Thu Sep 25, 2003 8:48 am
by Vincent Puglia
Hi

<input type="text" size="40" onFocus="this.blur();alert('Read Only')">

The alert isn't necessary, but it does give the user an idea of what is going on.

Re the 2fer:

send X number of arguments:

<a href="#" onClick="getCalendarFor(document.coupon.coupon_valid_from, document.coupon.coupon_valid_from_show);return false;">Choose Date</a>

and in the function, loop:

getCalendarFor()
{
var loopCnt = arguments.length;
for (var i = 0 ; i < loopCnt; i++)
{
someVar = arguments; // the nth argument being passed
....the function's code...
}

Vinny