hope some one can help - identifying href to servlet and checking checkbox
hope some one can help - evnafets, i notice you are online maybe you can help me again.
i have the following href attribute to a checkbox
and i need to onClick some how identify the checkbox to the controlling servlet to let it know what action to undertake
and also check the corressponding checkbox so that i can then have all the data associated with this checkbox.
i'm assigning a name to the href - and then trying to find the name to know that a href submit has been done - all my other submit actions have different names and can be found.
but i cant seem to figure out how to regonise the href click in the servlet.
also i 'm trying to in the javascript code check the checkbox - before doing a submit so that i can have the data related to the checkbox available in the request - but this gives a javascrpit error .
does any one know any javascript to know what i'm doing wrong.?
or maybe there is a better way of doing this in which case can some one please show me how the problem can be solved better - thanks
<a href="#" name="submit" onclick="checkbox.check; document.forms[0].submit(); return false;" />
checking by saying - thanks to evnafets posting yesterday
if (varSubmit ==null){
varSubmit = req.getParameter("submit") !=null ?"submit" :null;
}
[1673 byte] By [
mrsmalla] at [2007-10-2 5:32:12]

Hi,
Had some trouble getting at your requirement but think I finally managed.
the name you assigned to your href will not be available in the request object. Also, to make a checkbox checked you do
document.frm.mychkbox.checked = true.
Here's one approach you may follow:
function dosubmit() {
document.frm.submit();
}
<input type="checkbox" name="mychkbox" value="1">
<a href="#" onclick="javascript:dosubmit()" />
Also, it is bad design to check a checkbox before submitting as then the user gets no opportunity to see its status before the form gets submitted. You probably need a onChange event on your checkbox instead of a href.
Hope this helps.
cheers,
vidyut
thanks- how is an onchange event done and how would that help me - the only reason i'm following an opproach to check the checkbox is so that i have the data availble in the request object.
how will above herf action be identified by the servlet if name can not be supplied - how else can i know that the href link was clicked to do a submit to the post method.
and is there a better way of getting all the attributes of the checkbox without having to behind the scenes check the checkbox before doing a submit.
thanks
[nobr]this is still giving me problems - please can someone help me out.
i need to be able to
as part of extractResultsForm.txt I have a href attribute as below which is associated to a checkbox, along with other attributes.
<a href="#" onclick="javascript:dosubmit()"/>
This is shown on the results.htm
When the user clicks on this href I want to recognise that the user clicked the href as opposed to the other submit types that are possible on this form - eg. Its possible to tell the servelt to proceed with a drill down or to recreate the original list by doing a back submit action - so with those I can regonise them as in below
varSubmit = req.getParameter("back.x") != null ? "back" : null;
- where I use the parameter sent in with the submit button to regonise in my controller which type of action is needed - because it is an input type I know how to set its name and value - and thus regonise it in the servlet using varSubmit
<input type ="image" alt="Shrink List" value="submitList" name="submitList"
Q is - how can I regonise the href submit and how can I pass all the rest of the attributes of that particular checkbox which this href is associted to (see results.htm - for clearer understanding of what I mean)
thus, the form extract is:
><form name="myform" method="POST" action="CheckBoxListActionsS">
<table>
<tr><td>
<input type="checkbox" name="C1" value="Check All" onClick="this.value=check(this.form.list)">Select All
<% myAbridgments = (List) results.getAbridgments();
for (int i = 0; i < myAbridgments.size(); i++) {
myAbridgmentObj = (Abridgment) myAbridgments.get(i);
//abridgment = (Abridgment) myAbridgments.get(i);
//out.println(abridgment.geta_volume_id());
%>
<input type="checkbox" name="list" value="<%= i%>"><span style="font-size:12pt"><%= myAbridgmentObj.getSubYearVolume() %></span><span style="font-size:12pt">,
<a href="#" onclick="javascript:dosubmit()"/><%= myAbridgmentObj.getVolumeId() %></a>, </span><%= myAbridgmentObj.getBatchId() %>,<p:onmouseclick
hyperlinktype="url"
href="file://nc-fileshare-01/land%20and%20property/ROS%20Partnership/Management/Change%20Control/Active%20CCNs/CR%20003%20-%20Registers%20Archive%20Scanning/Technical/Design%20Workshops/Design%20Workshop/00000007.tif"/><span style="font-size:12pt;mso-color-index:6"><%= myAbridgmentObj.getImageId() %></span><span style="font-size:16pt;mso-color-index:6"> </span><br>
<%
}
%>
/// i have some submit buttons here which i regonise in the servlet - adn do accordingly - like sumbit View and sumbit List etc.... but want to be able to also regonise the a href="#" as submitt and also be able to retrieve the data associated with the checkbox where the heref is.
eg of checkbox format - the href is 10457 - i need to use it and probably10 Jul.1993 to be able to retrieve some more data if some one clicks on 10457
[]10 Jul.1993, (No.7), 10457, Bell, Brian, Fi 626.15
in the servlet for the other submit types i'm using following test to regonise the different types of submit by using the parameter name, but with a href submit dont know how to associate any names or any other key to be able to regonise it and also how do i associate the rest of the attributes of the check box with the submit of the single check box - one approach probabaly is to on click check the checkbox and then do a submit atleast thsi way i think i'll have all the attributes of the checkbox in the request object - but still i need to be able to regonise that the type of action that was done was a href submitt so that i can do accordingly - ie. use the parameters of the reuest accordingly. would this work if - so how is it possible - i would much appreciate a code example.
Thanks.[/nobr]
i dont seem to be getting much interest with this question - is no one able to undersatnd my requiremnet or is the question to difficult and what i ask for not actually possible?
You could do it in different ways.
Have a generic submit() function to submit your form.
Then have a hidden field in the form.
The submit() function accepts an attribute. This attribute tells the function about the caller - so when
1.The submit() button is clicked, it calls this function passing one attribute.
2. The the href is clicked, it calls this function passing a different attribute.
Based on the value of the passed in attribute, the hidden field value is populated differently and then the form is submitted.
In the servlet, the value of this hidden field tells it about the invoker.
Hope that helps.
ram.
thanks for the reply - atleast some one is offering to help.
i dont have any problems in identifying it in the servlet - i do that for the other sumits where i have name and values to the sumbit buttons the problem is i dont know how to set values in the href tab that i can then pick in the servelt
>i dont know how to set values in the href tab that i can then pick in the >servelt
Oh, I thought that was what I showed in the previous post. Lets try again- the click on href link calls a function which sets a value to a hidden attribute and submits the form.
The value of the hidden attribute tells the servlet that the form was submitted from a link.
<script>
function submitForm(type){
alert('here type = '+type);
document.f.linkClicked.value = type;
document.f.submit();
return false;
}
</script>
<form name = "f">
<input type = "submit" value = "go" onClick = "javascript:return submitForm('buttn')">
<input type = "hidden" name = "linkClicked">
</form>
Click <a href = "#" onClick = "submitForm('link')">here</a> to submit the form.
cheers,
ram.