embedding javascript in url
actully what i need to do is select particular options in a page through url;
ie for eg: if ther is a checkbox,, if i click on a particular link it shud be selected can anyone help me witht the script,. Thank you. |
Your question is impossible to understand, please be clear. Are you trying to design a web page having checkboxes (for what purpose)? If so, how is Javascript involved?
|
I mean I need not have to explicityly have to click on the check box, to select it.
better example; u have a certain multiple choice question on ur webpage and chkboxes to mark the answers. now i want to select the particular checkbox by entering javascript in the adress bar(ie i write the javascript wher we type the url) and the appropriate checkbox gets selected. thst the best I can Explain. thank you. |
Cannot imagine how that would be possible! You should check the box with a mouse click, or use the tab key to move to the check box (if you haven't got a mouse) and then check it using the space bar or so. Is this, by the way, a LinuxQuestions topic?
|
This almost works in FF and works even less well in IE when I tried it (but it does sort of work):
Code:
javascript:document.getElementById('checkbox').checked=true; But if you want to pass variables to a page through a GET request (in the URL) then you're going to need to use some kind of server-side language (like PHP) to output the correct Javascript code to your webpage. Or better yet, just have it write out the checkbox data with the value="checked" option. -Nick |
Code:
<html> |
Awesome. Works from the address bar too.
|
Here is a more general solution, then when it loads the page, it will be clicked if the address is like, http://www.somesite.com/page/asdf.html?checkthebox=1
Code:
<script> |
All times are GMT -5. The time now is 04:27 PM. |