Question: enabling and disabling a hyperlinks using javascript only

Ads

 
 
 

Share on Google+Share on Google+

Bharath Seshadri
enabling and disabling a hyperlinks using javascript only
0 Answer(s)      6 years and 6 months ago
Posted in : JavaScript Questions

Hi! can anyone help in enabling and disabling hyperlinks?. Question1: There is a frame set containing 2 frames a source frame containing 1.jsp and a destination frame containing 2.jsp. depending on a checkbox in 1.jsp a hyper link in 1.jsp should be enabled.And when the link is enabled only the page 2.jsp should be displayed in frame 2. Otherwise 2.jsp should not be displayed in frame2

 Following code is contained in the body of 0.jsp

    <html>
    <head>
    <frameset cols="50%,*">
        <frame id="sourceframe" name="sourceframe" src="./1.jsp"></frame>
        <frame id="resultframe" name="resultframe" src="./2.jsp"></frame>
        <BASE TARGET="resultframe">
    </frameset>
    </head>
    <body>
    </body>
    </html>

    following code is contained in 1.jsp

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>

    <link href="./css/calendar.css" rel="stylesheet" type="text/css">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Mother Earth's Arc for pets</title>
    </head>
    <body>
    <script language="javaScript" type="text/javascript" src="calendar.js">

    function disableLink()
    {

        document.getElementById('listOfOwners').disabled=true;
    document.getElementById('listOfOwners').removeAttribute('href');    
    document.getElementById('listOfOwners').style.textDecoration = 'none';
    document.getElementById('listOfOwners').style.cursor = 'default';
    }

    function showLink()
    {
        document.getElementById('listOfOwners').disabled=false;
    //assign href dynamically
    document.getElementById(listOfOwners.ClientId).href = "2.jsp";
    //document.getElementById("listOfOwners").setAttribute(href,"2.jsp");
    document.getElementById("listOfOwners").style.textDecoration = "underline";
    document.getElementById("listOfOwners").style.cursor = "hand";
    }*/
    function shouldDisplayOwnerDetailsOrNot(){
        //if(document.formPet.ownerExists.checked==true)
        //{
            frames['resultframe'].location.href = '2.jsp';
            alert("hello");
            //showLink();
            return true;

            //ownerLink_Enabled_Flag = true; 
        //}
        /*  
        else{
            frames['resultframe'].location.href = '';
            //disableLink();
            return false;
            //ownerLink_Enabled_Flag = false;

        }
        */  

    }
    <form name="formPet" action="Test.jsp" method="POST" onSubmit="">
    <table border="1" cellspacing="0" cellpadding
    ="0">
    <tr>
            <td><b>Owner Exists </b></td> <td><b><input type="checkbox" id="ownerExists" name="ownerExists" value="true"  checked>Owner Exists<br>
</b></td>
            </tr>
            <tr>
            <td><b>ListOfOwners </b></td> <td><input type="button" value="List Of Owners" id="listOfOwners" name="listOfOwners" 
onClick = "shouldDisplayOwnerDetailsOrNot();"
target="resultframe" >
            </td>
            </tr>
    </table>
    <input type="submit" value="Submit" ><br>
    </form>

    </body>
    </html>

Please correct the code above if possible.

Question 2:
Is there a solution using Java script only to achieve the problem described in http://www.webdeveloper.com/forum/showthread.php?t=174839

Or do we need to use php or any other scripting language
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
enabling and disabling a hyperlinks using javascript only
enabling and disabling a hyperlinks using javascript only  Hi! Anyone can help in enabling and disabling a hyperlinks?. Question1: There is a frame... using Java script only to achieve the problem descr
enabling and disabling a hyperlinks using javascript only
enabling and disabling a hyperlinks using javascript only  Hi! can anyone help in enabling and disabling hyperlinks?. Question1: There is a frame set... be enabled.And when the link is enabled only the page 2.jsp should be displayed
Advertisements
Java code for enabling filter to a checkbox and disabling filter to that checkbox after uncheked
Java code for enabling filter to a checkbox and disabling filter to that checkbox after uncheked  Can anybody say the Java code for enabling filter to a checkbox and disabling filter to that checkbox after uncheked
Enabling and Disabling Button In JSF
Enabling and Disabling Button In JSF  ...; In this tutorial enabling and disabling a button on different conditions has been...; then in the next page only one "Employee Area" button
Solve using only Javascript loops...
Solve using only Javascript loops...  Write a JavaScript code, 1) to find a number of unique letters in string. (Eg. if keyword is unique, Unique count will be '4') 2) so that numbers appear in following format, 1 1 2
displaying a calendar of only current month in jsp on webpage using javascript
displaying a calendar of only current month in jsp on webpage using javascript  how can we display a calendar of only current month in jsp on webpage using javascript
Disabling submit button using jQuery
Disabling submit button using jQuery  Hello Sir I want to know - is there any way or approach to disable client side form's "Submit" button. Please give code also.   For all submit buttons, via JQuery, it'd
disabling commandlink
disabling commandlink  how can i disable commandlink through javascript. My requirement is that once the link is disabled the user should not be able to click on it. The commandlink.disabled attribute only disables the link
creating hyperlinks in applet - Applet
creating hyperlinks in applet  Dear sir, how can i move from one applet to another applet and how can i use previous applet input data in anotherapplet(just like session tracking) thanks
To change the color of text hyperlinks midway
To change the color of text hyperlinks midway   Is there a way to change the color of text hyperlinks midway through a page? If so, what code do I use
To change the color of text hyperlinks midway
To change the color of text hyperlinks midway   Is there a way to change the color of text hyperlinks midway through a page? If so, what code do I use
To change the color of text hyperlinks midway
To change the color of text hyperlinks midway   Is there a way to change the color of text hyperlinks midway through a page? If so, what code do I use
Date object using JavaScript
Date object using JavaScript  What's the Date object using JavaScript
delete an entry using JavaScript
delete an entry using JavaScript  How to delete an entry using JavaScript
using for loop in javascript
using for loop in javascript  How to use for loop in JavaScript
Enabling the textbox - Java Server Faces Questions
Enabling the textbox  Hi, I have disabled the jsf text box using JavaScript on clicking the select boolean check box and it's getting disabled too. but when I am trying to enable it again on clicking of checkbox
Jsp code for disabling record.
Jsp code for disabling record.  I want a Jsp and servlet code for the mentioned scenario. Q. A cross sign appears in front of each record, click... in Advance from my side. I am using MyEclipse and DB2
Disabling Login Functionality
Disabling Login Functionality  I have a textarea box, on clicking which the login box appears. When the user enters his login credentials... this onclick functionality when the user is already in session. I am using onclick
timer using javascript
timer using javascript  How to display timer on HTML page using JavaScript
maximize an image using javaScript
maximize an image using javaScript  Write the code to maximize an image using javaScript
xls to js using javascript
xls to js using javascript  ![how can we convert a xls file in js file using javascript][1
JQuery-Disabling element in JQuery.
JQuery-Disabling element in JQuery.   How can we enable/disable an element in JQuery
send mail using JavaScript
send mail using JavaScript  How can we send mail using JavaScript?   Hi friends, You can not send email directly using JavaScript. But you can use JavaScript to execute a client side email program send the email using
disabling the browser's back button
disabling the browser's back button  I have following requirement, After submitting the form, user should not navigate to the previous page. I have tried with onbeforeunload(), but it is not working properly. Please help me
How to make session control using only JSP programming language
How to make session control using only JSP programming language  Could i do Controlling session using only JSP programming language without using anylanguage
How to shift and unshift using JavaScript?
How to shift and unshift using JavaScript?  How to shift and unshift using JavaScript
disabling back button
disabling back button  hi, i am trying to make an application and i stuck at the point after login.. when i could logged in successfully then if i press back button i again reach to the back page ie. authentication page so if any
validate radio button using javascript
validate radio button using javascript  validate radio button using javascript
checkboxes set to true using JavaScript
checkboxes set to true using JavaScript  To set all checkboxes to true using JavaScript
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
associate functions with objects using JavaScript
associate functions with objects using JavaScript  How to associate functions with objects using JavaScript
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads