dolan2go
asked on
Javascript - Using function repeatedly
How to use the return of the function in simplified way? The code below returns true or false. I'd like to put it into a php variable and have this occur on the loading of the page.
To be used later like:
Thanks
<html>
<head>
<script type="text/javascript">
function supports_input_placeholder ( )
{
var i = document.createElement("input");
return "placeholder" in i;
}
</script>
</head>
<body>
<script type="text/javascript">
document.write(supports_input_placeholder())
</script>
</body>
</html>
To be used later like:
<input type="text" <?php if $place_holder { echo "placeholder=\"10 digit number\""; } maxlength="16" />
I do know one is server side and one is client side.Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The intent is to arrive at a simpler (and working) method of this:
() returns 'true'.
<input type="text" name="text" <script type="text/javascript"> var p = s_i_p(); if (p == true) { document.write("placeholder=\"10 digit number\""); } </script> class="input_phone" maxlength="16" />
in lieu of:<input type="text" name="text" placeholder="10 digit number" class="input_phone" maxlength="16" />
only if the function supports_input_placeholderASKER
Long overdue.
ASKER
How to put the return into a php variable or Session variable? Like $place_holder in the one line of code <input> above.