According to another question, you can view your skin with this code:
<applet code="net.minecraft.skintest.ModelPreviewApplet"
archive="http://www.minecraft.net/skin/skintest.jar" codebase="."
width="320" height="320">
<param name="name" value="535" />
</applet>
Which works!
But does anyone knows how i can make a textbox and a button which puts the written text in the value="535" tag (replaces "535" with the text box input)?
Link to the other question: Is there a web-embeddable skin preview application?
You can write your applet into the DOM at run-time like this:
<div id="wrapper"></div>
<input type="text" value="" onchange="writeApp(this.value)">
<input type="button" value="go">
<script type="text/javascript">
function writeApp(pVal) {
document.getElementById('wrapper').innerHTML = '<applet code="net.minecraft.skintest.ModelPreviewApplet" archive="http://www.minecraft.net/skin/skintest.jar" codebase="." width="320" height="320"><param name="name" value="'+pVal+'" /></applet>'
}
</script>
Strangely enough, the applet doen't seem to like values other than "525"
That should be easy, but I don't think it will do what you want it to do.
I'm assuming you want to have a preview window with the texture preview, and allow users to type in new texture IDs, push the button, and see the preview right away.
Simply changing the value of the param after the page has loaded won't accomplish that.
When the button gets pushed, you'll need to remove the applet and re-create it, with the new param value in order for the changes to take effect.
Here's the code you asked for:
<applet
code="net.minecraft.skintest.ModelPreviewApplet"
archive="http://www.minecraft.net/skin/skintest.jar" codebase="."
width="320"
height="320">
<param name="name" id="previewName" value="535" />
</applet>
<input type="text" id="newValue" />
<script>
document.getElementById('newValue').onblur = function(event) {
// grab value
var iVal = parseInt(this.value);
if(!iVal && iVal !== 0) return;
// update param
document.getElementById('previewName').value = iVal;
return true;
};
</script>
If you try that and it doesn't accomplish what you wanted, let me know and I can write the code that will do it.
Related
In my application, I have got an image as a button. When I record the button click event in Selenium IDE and replay it, i merely plays it back but the click event is not actually submitting the value
Ex: The submit button (which is an image) should actually submit the value to database. But when I check in the database, the value is not added there
Element Value
<input width="98" vspace="3" type="Image" height="15" border="0"
id="Image1" src="images/butt_submit.gif" value="Submit" name="Submit">
Selenium Code
selenium.click("//input[#id='Image1']");
selenium.waitForPageToLoad("30000");
Please assist.
Thanking you!
HG
The issue is not with Selenium/IDE not clicking the image. The code you're using (in HTML) will not submit the form data even if you did it manually. Did you check that first?
Anyway, if you want to use an image as the submit action for a form, add an onclick event for the image to submit the form. See this example on W3Schools for form.submit:
<html>
<head>
<script>
function formSubmit()
{
document.getElementById("frm1").submit();
}
</script>
</head>
<body>
<form id="frm1" action="form_action.asp">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formSubmit()" value="Submit form">
</form>
</body>
</html>
They are using a button here but you can use that for your image.
More about HTML Forms basics: http://www.w3schools.com/html/html_forms.asp
Folks,
I am trying to add a DateTimePicker javascript file in one of the screen. On clicking the calender icon, the calender is not getting poped up.
I added the javascript file in the public/javascript folder and the image in the public/images folder.
Then I added this line in main.html:
<script type="text/javascript" src="#{'/public/javascripts/datetimepicker_css.js'}" ></script>
and this line for diaplsying the image beside the textbox:
<input type="text" styleId="demo1" name="transaction.returnDate" size="10">
<img src="#{'/public/images/cal.gif'}" onclick="javascript:NewCssCal('demo1')" style="cursor:pointer"/>
When the screen is loaded, the image is getting diaplsyed properly beside the textbox. But when I click it, the calendar is not getting displayed.
I use these two lines in my other struts application and it works fine:
<script language="javascript" type="text/javascript" src="/MediaTest/datetimepicker/datetimepicker_css.js">
<html:text styleId="demo1" name="returnForm" property="returnDate" size="10"></html:text>
<img src="/MediaTest/datetimepicker/cal.gif" onclick="javascript:NewCssCal('demo1')" style="cursor:pointer"/>
Please let me know how to make it work.
Thanks,
change styleId attribute to id
<input type="text" id="demo1" name="transaction.returnDate" size="10">
I'm trying to use jQuery with JSP to display a table where in each row there are three possible actions: Up, Down, Refresh. I want to display an image for each even next to each other and be able to click the buttons in each row to perform the requested operation (up/down/refresh) as defined in my Java code. So it will be a different action/function executed for each button, and each row. For example: Row 1 actions would be: modelUp, modelDown, modelRefresh; row 2 actions would be: productionUp, productionDown, productionRefresh; ... etc.
The problem is I don't know jQuery and have little to no experience with JSP. I've been Google'ing, but it hasn't gotten me very far.
Can someone help me out? Thanks.
Basically you attach an action to a CSS selector in jQuery by using
$('.classname').bind('click', function() {
// do something
});
This will execute the code whenever something that has class .classname is clicked.
In your situation you will have 3 classes, one for each kind of button. How to specify the custom behavior is your choice. You could attach some custom attribute to every DOM element of every row so that inside the click function you are able to distinguish between them and do different actions accordingly.
Mind that this is a good design just if you can use this attribute without cluttering your click function with a long chain of if/else, otherwise you'd better have many different actions bound to every button. Since you are working with JSP you can generate JS code dynamically when the resulting HTML is generated for the client.
Ok, I pretty much solved most of it this way.
Here's my JSP (this is only one row of the table, but the rest follow the same scheme):
'code
<form id="checkStatusForm" action="<%= model.getUri() %>" method="post" >
<input type="hidden" name="<%=FrameworkConstants.FRAMEWORK_COMMAND%>" value="checkstatus" />
<input type="hidden" name="<%=FrameworkConstants.FRAMEWORK_GUID%>" value="<%=model.getPageId()%>" />
<input type="hidden" name="regionID" id="regionID" value="" />
<input type="hidden" name="regionAction" id="regionAction" value="" />
<img src="<%=request.getContextPath() %>/images/up.jpg" alt="" name="modelUp" width="20" height="20" id="modelUp" onclick="CheckStatus.performRegionAction('model', 'up')" />
<img src="<%=request.getContextPath() %>/images/down.jpg" alt="" name="modelDown" width="20" height="20" id="modelDown" onclick="CheckStatus.performRegionAction('model', 'down')" />
<img src="<%=request.getContextPath() %>/images/refresh.png" alt="" name="modelRefresh" width="20" height="20" id="modelRefresh" onclick="CheckStatus.performRegionAction('model', 'refresh')" />
<button type="submit" style="margin-left: 2px; margin-top: 5px; margin-bottom: 0px;" >Commit Changes</button>
</form>
'
Here's my jQuery/Javascript:
'code
performRegionAction : function(regionID, regionAction){
document.getElementById('regionID').value = regionID;
document.getElementById('regionAction').value = regionAction;
},'
And finally here's my Java:
'
public void setRegionID(Field<String> regionID){
this.regionID = regionID;
}
public Field<String> getRegionID(){
return this.regionID;
}
public void setRegionAction(Field<String> regionAction){
this.regionAction = regionAction;
}
public Field<String> getRegionAction(){
return this.regionAction;
}
'
Iam new to JSP and i can't seem to figure out how to run code only when the user clicks on the button..here's my code:
$
<form action="list_computers.jsp" method="post">
Search:
<input type="text" name="FromTextBox1"/>
<input type="submit" value="Search it!" >
<%
String TheSearch = (String)request.getParameter("FromTextBox1");
String GetIt = Searcher(TheSearch);
out.println(GetIt);
%>
</form>
The Searcher() is a function i declared above this. Any help would be really appreciated.
You need to do something like
if (request.getParameter("submit") != null) {
// do work here
}
You also need to give a name to your button
<input type="submit" value="Search it!" name="submit">
When user clicks (or presses enter), request['submit'] will be equal to "Search it!"
I highly recommend moving this logic to the top of the page or even better to a controller.
you need to use javascript to check for the onclick event here's a little example with JQuery
$("input[type='submit']").click(function(){
//do your thing
// use event.preventDefault(); to stop submission if need
});
Using IE 7, JDK 1.6 and Sun Web server 7.
Inside the jsp form, we have:
<input type="text" name="id" maxlength="20" />
<input ... type="submit" name="send" value="Send"/>
i.e. a text box and a "Submit" button (called Send).
and the servlet has:
if (request.getParameter("send") != null && request.getParameter("send").trim().length() > 0) { ... }
Using Fiddler and IE, we can see that the following is sent when we populate the id text box and hit Enter:
id=123456
However, using Fiddler and IE, we can see that the following is sent when we populate the id text box and click the Send button:
userId=123456&send=Send
The end result is that hitting the Enter key effectively does nothing.
On other jsp pages, e.g. we have:
<input type="text" name="id" maxlength="20" />
<input ... type="submit" name="submitId" value="Submit"/>
and the servlet has:
if (request.getParameter("submitId") != null && request.getParameter("submitId").trim().length() > 0) { ... }
Using Fiddler and IE, we can see that the following is sent for both cases:
id=123456&submitId=Submit
So it seems to us that the behaviour is only exhibited on IE for forms where the "Submit" button is not called "Submit"?
Re-running the tests on Firefox 3.6 shows that the behaviour is correct and the same for both cases.
Any suggestions for getting IE to work correctly?
(Note: I have searched SO for a similar problem but the questions relating to this mainly all ASP related!).
This is indeed another IE anomaly in case of forms with only one input field. The only solid workaround for this is to add a second input field(!). You can hide it using CSS. No, type="hidden" ain't going to work.
<input type="text" name="id" maxlength="20" />
<input type="text" style="display: none;" />
<input type="submit" name="send" value="Send"/>
Why are you checking for request.getParameter("submitId") in your JSP when in fact submitId is the name of your submit button?
In my experience I never had to check the value for the submit button. I only used that button to trigger the form submit and would usually only be interested in retrieving the values for the other form parameters.
If you want to differentiate the submit methods by the name of the submit button, you might want to try adding a "hidden" property using input type="hidden".