Sinisterly
Need help here with 2 javaScript problems - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Java, JVM, & JRE (https://sinister.ly/Forum-Java-JVM-JRE)
+--- Thread: Need help here with 2 javaScript problems (/Thread-Need-help-here-with-2-javaScript-problems)



Need help here with 2 javaScript problems - privateloader - 07-28-2015

I need a HTML select box that converts into a javascript var test_id.
But i don't know where to put id="test_id" in the select code.

Example:

<script>
test = function() {
var test_id = escape(document.getElementById('test_id').value);
alert('selected');
return false;
}
</script>

<form>
<select>
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="submit" name="submit" value="Submit" onclick="test">
</form>

::::::::::::The second part::::::::::::

After adding the id element
i need to convert the value 1 (test_id) into 2 or more diferent vars

Example step by step:

Selected => 1
confirms that 1 is selected
and converts into 1a and 1b (both are javascript vars) that can be call inside the javascript.

Thanks


RE: Need help here with 2 javaScript problems - Dyme - 07-28-2015

I fixed your nasty ass code so at least now test_id is receiving the selected option. I don't really know what you want for the "second part"... you're gonna have to explain it better if you want more help.

Code:
<html>
<script>
function test() {
    var test_id = escape(document.getElementById('test_id').value);
    alert(test_id);
    return false;
}
</script>

<form onsubmit="test()">
<select id="test_id">
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="submit" name="submit" value="Submit">
</form>
</html>



RE: Need help here with 2 javaScript problems - Satan - 07-28-2015

(07-28-2015, 08:45 PM)Dyme Wrote: I fixed your nasty ass code so at least now test_id is receiving the selected option. I don't really know what you want for the "second part"... you're gonna have to explain it better if you want more help.

Code:
<html>
<script>
function test() {
    var test_id = escape(document.getElementById('test_id').value);
    alert(test_id);
    return false;
}
</script>

<form onsubmit="test()">
<select id="test_id">
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="submit" name="submit" value="Submit">
</form>
</html>

He means if 1 is selected, then it gives options 1a 1b, I think.

E.g.

[Image: w0Jd3SC.png]

Though, I don't know for sure, so maybe not. He wasn't very clear on that.


RE: Need help here with 2 javaScript problems - privateloader - 07-29-2015

Hi thanks for the help, here is the details

I'm using a simple form to submit two or more forms and one of the select fields are diferent.

I want the value of test_id to be assign to diferent vars

For example (The sckety scheme using countries)
test_id is 1
if test_id is 1 create a javascript var test_id1 with value USA
if test_id is 1 create a javascript var test_id2 with value 34
if test_id is 1 create a javascript var test_id3 with value 85

Then i will call the javascript vars when needed in a form using document.write(); ["+test_id+"]


RE: Need help here with 2 javaScript problems - privateloader - 08-01-2015

Thanks i have all i need for this project


RE: Need help here with 2 javaScript problems - Penis - 10-09-2015

Two things:

1. I feel like we're gonna see this code in some "new" malware, shame we didnt take the opportunity to mess with it
2. How the fuck is Java, JVM, & JRE == JavaScript?