Onchange Event in Dropdown
Collapse
X
-
-
The output of your above code is as follows..
while i select INDIA from drop down, a confirm box comes up with a question: Are you a INDIA citizen( where value is taken as INDIA).. But this is not my concern, my concern ihere s when the user clicks OK or CANCEL then i want this action to be recorded or stored in a variable, and this value should be stored in a text boxComment
-
To assign it to a text box:
This would require a submit to be passed to ASP. Another option is to pass it in the URL and change the page immediately:Code:document.getElementById("textboxid").value = val;
If you want to avoid a page reload, use Ajax.Code:location.href = "asppage.asp?val=" + val;
Comment
-
Comment
-
you can write like
document.getEle mentById('txtbo x').innerHTML = 'INDIA'
Dormilich i remove echo from my code even then it is not workingComment
-
sorry Dormilich i am still unable to understand. please tell me what should i write exactly
Code:<?php $country = echo '<script type="text/JavaScript"> value; </script>'; ?>
Comment
-
Besides the PHP problem, you're mixing JavaScript and PHP incorrectly. You can use PHP (or any server-side language) to generate JavaScript code during page load, but you can't use this kind of code to run PHP after the page has loaded.Comment
-
In vbscript, i am using message box If the user clicks OK button.. I want to assing a value to a text box <input>..Plea se help me out in this
Code:<Script lang="VBScript> dim a dim res= Yes a=MsgBox("you pressed ok",VbYesNo) if a = VbYes then <i want to assign the variable "res" to a text box below> </script> <html> <head><body> <input type="text" name="test" value=''> </head></html>Comment
-
As there is NO window object with YES and NO buttons in Javascript, i am making use of both Javascript and VB script..
In javascript i am using selectedIndex to track the selected item from the drop down, within IF conditon i am calling VBscript function(contai ns a MsgBox) if the result is true...
Now within VBscript i need to write a condition, If the user clicks on Yes button then i want to assign some value to a textbox so that i can save this text box value in the database.Comment
-
You do realise that this would restrict your site to IE only? You can phrase your question so that the options for confirm() (OK/Cancel) are suitable. Are you sure you still want to go with VBScript?
If you do, the method will be similar to what has been suggested earlier. Set the value of the text box like this:
where "textboxid" is the ID of the text box and val is the value that needs to be assigned.Code:document.getElementById("textboxid").value = val;Comment
-
Thanks for the reply.
But as per the requirement, YES or NO should be the only options..that is the reason i am using VBscript... Anyways i will speak to the requestors regarding the above subject... If i am using VBscript what will be the syntax in VBscript to assign a value to a text box..??Comment
Comment