Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8673185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:23:39+00:00 2026-06-12T19:23:39+00:00

I got a JSFIDDLE and trying to get it to work on my web

  • 0

I got a JSFIDDLE and trying to get it to work on my web form but it is not woorking. Can anyone please tell me what mistake i am making. The JSFIDDLE is working perfectly fine but i am not able to get it to work at my page only. This is the link to the fiddle: LINK

And this is how i am trying to use it :

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
var devices = ['computer', 'router']
var device_types = {
    'computer': ['laptop', 'desktop'],
    'router': ['wireless', 'bluetooth']
}

var brands = {
    'laptop': ['HP', 'DELL'],
    'desktop': ['Apple', 'MAC'],
    'wireless':['Foo','Bar'],
    'bluetooth':['Grren','Blue']
}


function createOptions(arr) {
    var html = ['<option >--select--</option>'];
    $.each(arr, function(i, item) {
        html.push('<option value="' + item + '">' + item + '</option>')
    });
    return html.join('');
}

var mainOptions = createOptions(devices)

$(function() {
    $("input[type=button][value=Add]").click(function(e) {
        for (i = 0; i < document.getElementById('sel').value; i++) {
            e.preventDefault();
            var j = 1;

            var newDiv = $('<div class="row">').appendTo("#dropbox");
            $("<select class='devices has_dependents'>").attr("name", "input1_" + j).append(mainOptions).appendTo(newDiv)

            $("<select class='device_types has_dependents'>").attr("name", "input2_" + j).appendTo(newDiv)
            $("<select class='brands'>").attr("name", "input3_" + j).appendTo(newDiv)
            $("<input>").attr("name", "input4_" + j).appendTo(newDiv);
            $("<button>").text("Remove").appendTo(newDiv).click(function(e) {
                e.preventDefault();
                $(this).parent().remove();
            })
            j++;
        }
    });

    $(document).on('change', 'select.has_dependents', function() {
        var val = $(this).val(),
            option_obj;
        if ($(this).is('.devices')) {
            option_obj = device_types;
        } else {
            option_obj = brands;
        }


        var options = createOptions( option_obj[val]);


        $(this).next().html(options)
    })
})
</script>
</head>

<body>
<form>
    <select id="sel">
        <option value="" selected="selected"></option>
        <option value="01" >01</option>
        <option value="02" >02</option>
        <option value="03" >03</option>
        <option value="04" >04</option>
        <option value="05" >05</option>
        <option value="06" >06</option>
        <option value="07" >07</option>
        <option value="08" >08</option>
        <option value="09" >09</option>
        <option value="10" >10</option>
        <option value="11" >11</option>
        <option value="12" >12</option>
        <option value="13" >13</option>
        <option value="14" >14</option>
        <option value="15" >15</option>
    </select>
    <input type="button" value="Add" />

    <div id="dropbox"></div>
</form>​
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:23:40+00:00Added an answer on June 12, 2026 at 7:23 pm

    line 67 there is a non-visual character just after the ‘)’

    })<right here is a none visual character>
    </script>
    

    Edit:
    heres a link to the fixed code:

    http://pastebin.com/8n8fkgMy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I got: http://jsfiddle.net/nCs88/ What I'm trying to get: http://img545.imageshack.us/img545/888/42576e33afe343a0bab6a40.png I'm an absolute beginner,
All, I've got the following JS Fiddle: http://jsfiddle.net/HHtBX/11/ I'm trying to basically close all
I've got a toggle menu, please see http://jsfiddle.net/Wp2em/41/ for code and functions. On the
http://jsfiddle.net/motocomdigital/uTV5k/18/ I've updated using toggle instead on click - though still can't get smooth
I'm trying to basically replicate the Starbucks mobile navigation but I can't figure out
I'm trying to take content from a list (but not including the LI tag
Never had problems with centering divs before but I have been trying to get
I have got an example here: http://jsfiddle.net/cByhZ/ As you can see the buttons value
http://jsfiddle.net/jX7An/3/ I've got the code that can be seen on jsfiddle above. I can't
I've got a problem which you can look at here http://jsfiddle.net/dng2P/4/ If you click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.