You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by john lee <sh...@yahoo.com.INVALID> on 2014/07/25 21:30:47 UTC
s:textfield jquery can not change placeholder
I can use jquery to change html input tag's placeholder for no problem, but no matter what method I use, impossible for me to change
s:textfield's placeholder.
I tried
$('#partid').attr('placeholder','XXX');
and
$('#partid').val('XXX');
and
$('#partid').text('XXX');
s:textfield's placeholder impossible for jquery to change, is struts2 limition or bugs?
thanks in advance
john
*************************************************************
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<sj:head jqueryui="true"/>
<script language="javascript">
$(document).ready(function() {
$('#searchchoice').change(function() {
var ex = document.getElementById("searchchoice");
var finalchoice = ex.options[ex.options.selectedIndex].text;
if (finalchoice=='part#')
$('#partid').attr('placeholder','input example: XXX');
else if (finalchoice=='keyword')
$('#partid').attr('placeholder','input example 2: XXX');
else if (finalchoice=='model')
$('#partid').attr('placeholder','input example 3: XXX');
});
});
</script>
<s:form class="nav-search" action="PartsearchbothAction" method="post" theme="simple" >
<s:select label="Part#"
id="searchchoice"
name="searchchoice"
list="#{'part#':'part#', 'keyword':'keyword', 'model#':'model'}"
value="part#"
theme="simple"
required="true"
/>
<s:textfield name="partid" label="partid" placeholder='default search is by Part#' required="true" theme="simple"/>
<s:submit value="go">
</s:form>
Re: s:textfield jquery can not change placeholder
Posted by john lee <sh...@yahoo.com.INVALID>.
Thanks Chris.
It is solved after apply ID
On Friday, July 25, 2014 3:04 PM, Chris Pratt <th...@gmail.com> wrote:
Make sure you set the "id" attribute on the s:textfield if you're going to
refer to it that way using jQuery.
(*Chris*)
On Fri, Jul 25, 2014 at 12:30 PM, john lee <sh...@yahoo.com.invalid>
wrote:
>
> I can use jquery to change html input tag's placeholder for no problem,
> but no matter what method I use, impossible for me to change
> s:textfield's placeholder.
> I tried
> $('#partid').attr('placeholder','XXX');
> and
> $('#partid').val('XXX');
> and
> $('#partid').text('XXX');
>
> s:textfield's placeholder impossible for jquery to change, is struts2
> limition or bugs?
>
> thanks in advance
>
> john
>
> *************************************************************
>
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
> <sj:head jqueryui="true"/>
>
> <script language="javascript">
> $(document).ready(function() {
> $('#searchchoice').change(function() {
> var ex = document.getElementById("searchchoice");
> var finalchoice = ex.options[ex.options.selectedIndex].text;
> if (finalchoice=='part#')
> $('#partid').attr('placeholder','input example: XXX');
> else if (finalchoice=='keyword')
> $('#partid').attr('placeholder','input example 2:
> XXX');
> else if (finalchoice=='model')
> $('#partid').attr('placeholder','input example 3:
> XXX');
>
> });
> });
> </script>
>
> <s:form class="nav-search" action="PartsearchbothAction" method="post"
> theme="simple" >
> <s:select label="Part#"
> id="searchchoice"
> name="searchchoice"
> list="#{'part#':'part#', 'keyword':'keyword',
> 'model#':'model'}"
> value="part#"
> theme="simple"
> required="true"
> />
> <s:textfield name="partid" label="partid" placeholder='default
> search is by Part#' required="true" theme="simple"/>
>
> <s:submit value="go">
> </s:form>
Re: s:textfield jquery can not change placeholder
Posted by Chris Pratt <th...@gmail.com>.
Make sure you set the "id" attribute on the s:textfield if you're going to
refer to it that way using jQuery.
(*Chris*)
On Fri, Jul 25, 2014 at 12:30 PM, john lee <sh...@yahoo.com.invalid>
wrote:
>
> I can use jquery to change html input tag's placeholder for no problem,
> but no matter what method I use, impossible for me to change
> s:textfield's placeholder.
> I tried
> $('#partid').attr('placeholder','XXX');
> and
> $('#partid').val('XXX');
> and
> $('#partid').text('XXX');
>
> s:textfield's placeholder impossible for jquery to change, is struts2
> limition or bugs?
>
> thanks in advance
>
> john
>
> *************************************************************
>
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
> <sj:head jqueryui="true"/>
>
> <script language="javascript">
> $(document).ready(function() {
> $('#searchchoice').change(function() {
> var ex = document.getElementById("searchchoice");
> var finalchoice = ex.options[ex.options.selectedIndex].text;
> if (finalchoice=='part#')
> $('#partid').attr('placeholder','input example: XXX');
> else if (finalchoice=='keyword')
> $('#partid').attr('placeholder','input example 2:
> XXX');
> else if (finalchoice=='model')
> $('#partid').attr('placeholder','input example 3:
> XXX');
>
> });
> });
> </script>
>
> <s:form class="nav-search" action="PartsearchbothAction" method="post"
> theme="simple" >
> <s:select label="Part#"
> id="searchchoice"
> name="searchchoice"
> list="#{'part#':'part#', 'keyword':'keyword',
> 'model#':'model'}"
> value="part#"
> theme="simple"
> required="true"
> />
> <s:textfield name="partid" label="partid" placeholder='default
> search is by Part#' required="true" theme="simple"/>
>
> <s:submit value="go">
> </s:form>